Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Kingware, AndrewAMD, AemStones, RealSerious3D, degenerate_762), 837 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[ANET] Send Username and Password with char #342135
09/23/10 22:15
09/23/10 22:15
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Hi,

i´m trying to send username and password via char array (hope this is the correct way)

my script looks like this.

Sending.

Code:
function login_start(var sender, STRING* msg)
{
	inkey(username);
	
	char sendchr[1];
	
	sendchr[0] = username;
	
	enet_clsend_event(19, sendchr, 1, SERVER);
}



how do i know receive this data? if i use a char pointer i only get annoying signs.

Is therwe another way?

Re: [ANET] Send Username and Password with char [Re: Rasch] #342146
09/24/10 06:39
09/24/10 06:39
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Why don't you send the whole char array?

Code:
function login_start(var sender, STRING* msg)
{
        char username[30];
	inkey(username);
	
	enet_clsend_event(19, username, str_len(username), SERVER);
}

function ev_username(var sender, STRING* msg, var size)
{
        char username[30];
        memcpy(username,_CHR(msg),size);
}



But why using a char array and not a String?

Code:
function login_start(var sender, STRING* msg)
{
        STRING* username = "#30";
	inkey(username);
	
	enet_clsend_event(19, username, 0, SERVER);
}

function ev_username(var sender, STRING* msg, var size)
{
        error(msg);
}




ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Send Username and Password with char [Re: Dark_samurai] #342149
09/24/10 08:11
09/24/10 08:11
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Hi Samurai,

thanks for the reply. I forgot soemthign in the script. I can use strings. It works good but i just want to have it easier.

This is my real function atm.

Code:
function login_start(var sender, STRING* msg)
{
	inkey(username);
	inkey(password);
	
	STRING* info_send = "";
	str_cpy(info_send, username);
	str_cat(info_send, ",");
	str_cat(info_send, password);
	
	enet_clsend_event(19, info_send, 0, SERVER);
}



I´m sending "username,password" to hte server.

THe server receives this. I´m then using a method of str_len, str_trunc, str_clip to cut this info back into username and password. THat works. But is just too much of code. So i wanted it easier.

How would it look now if i would send username and password together? (please use my code as example)

A last question. What is the memcpy function? I dont have this command. Is it integrated in ANET?

Really much thanks for your help laugh

Re: [ANET] Send Username and Password with char [Re: Rasch] #342158
09/24/10 08:50
09/24/10 08:50
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
You could make a char array like that:

[username][0][password][0]

memcpy() is a windows function. It copies the the content of the array of the second parameter into the array of the first parameter. The third parameter determines the size of the content that should be copied.

So you could do it like that:

Code:
function login_start(var sender, STRING* msg)
{
   char temp_array[100];

   inkey(username);
   inkey(password);

   memcpy(temp_array, username, str_len(username)+1); //also copies the zero termination of username
   memcpy(&temp_array[str_len(username)], password, str_len(password)+1); //also copies the zero termination of password

   enet_clsend_event(19, temp_array, str_len(username)+str_len(password)+2, SERVER);
}

function ev_username(var sender, STRING* msg, var size)
{
   char temp_array[100];
   char username[30];
   char password[30];

   memcpy(temp_array,_CHR(msg),size);

   str_cpy(username, temp_array); //copies everything to the first zero termination
   str_cpy(password, &temp_array[str_len(temp_array)+1]); //copies everything to the second zero termination
}



It's not shorter, but has the advantage that you can use "," in the username and password.
Btw. it's not tested, so I can't guarantee that it's working.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANET] Send Username and Password with char [Re: Dark_samurai] #342163
09/24/10 08:57
09/24/10 08:57
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Ok thanks that looks interesting. It´s a little bit shorter. Thats good laugh

I´ll try it out later.

Thanks


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1