Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (AndrewAMD), 1,643 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Weird str_to_num problem #211403
06/16/08 14:35
06/16/08 14:35
Joined: Oct 2004
Posts: 290
Latvia
Leonardo Offline OP
Member
Leonardo  Offline OP
Member

Joined: Oct 2004
Posts: 290
Latvia
I'm trying to make an account system for a small MP application, but I ran into a very weird problem today smile
Here's the code:

Code:
If(str_len(username_str) > 5 && str_len(password_str) > 5 && player == null)
	{
		str_cpy(id_str,player_name);
		str_clip(id_str,6);
		client_id1 = str_to_num(id_str);
		player = ent_create("arrow.pcx",vector(1000,1000,1000), mp_entity);
		sleep(1);
		player.ID = client_id1;
		send_skill(player.ID,0);
		str_cpy(login_command,id_str);
		str_cat(login_command,"*");
		str_cat(login_command,username_str);
		str_cat(login_command,"*");
		str_cat(login_command,password_str);
		send_string(login_command);
	}


username_str, password_str and id_str are strings, client_id1 is a variable... what I'm trying to do, is get a unique client ID by clipping 6 characters off of the string "player_name", then turning it into a variable using str_to_num and then send it to the newly created player entity.
Now, the problem is - client_id1 isn't the same as id_str!! No matter what I do, client_id1 just looks like a random number every time! But id_str is correct - if player_name is, for example, Client8141723, then id_str is 8141723...
I have checked every line of my code, I don't have variables with the same name, or something like that, so what's wrong?

Last edited by Leonardo; 06/16/08 14:38.

"Things of the mind left untested by the senses are useless."
Re: Weird str_to_num problem [Re: Leonardo] #211444
06/16/08 18:50
06/16/08 18:50
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
1. over flow problem for var type
--see max value for var (999,999.999?)
--sample var in post was > 8 million (not 6 chars)?
--difficulty in counting digits?
----might be typical for scope
2. variables may change on sleep, wait, etc.
3. performance: ? no short circuit (&&, &&, &&)
--do separately and skip if false?



Re: Weird str_to_num problem [Re: testDummy] #211446
06/16/08 19:02
06/16/08 19:02
Joined: Oct 2004
Posts: 290
Latvia
Leonardo Offline OP
Member
Leonardo  Offline OP
Member

Joined: Oct 2004
Posts: 290
Latvia
That is just great.... the thing about programming is that - it's not the big problems that make me mad, it's these small, insignificant little things that just drive me crazy!!
But thank you, the over-flow problem was the right one smile


"Things of the mind left untested by the senses are useless."

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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