Troubles converting variables - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Troubles converting variables (
/showthread.php?tid=72740)
Troubles converting variables -
Ellis - 10.04.2009
I would like to know what is the problem with this script:
pawn Код:
public OnPlayerText( playerid, text[ ] )
{
new
tmpvalue = strval( text );
printf( "%d", tmpvalue );
new
string[ 156 ];
format( string, 155, "Written number: %d", tmpvalue );
SendClientMessage( playerid, COLOR_WHITE, string );
return false;
}
Do not pay attention to variables size, because it's just a test script. When i write a text in-game i get letters " ''I " or something like that. It seems that convertation is completed successfully judging by a console but trust me, it's not.
Re: Troubles converting variables -
tom_jonez - 10.04.2009
the command strval converts a string to an integer. remove that and replace your tmpvalue variable with text.
Re: Troubles converting variables -
Ellis - 10.04.2009
Well, i actually need text to be converted to integer.
Re: Troubles converting variables -
tom_jonez - 10.04.2009
Well than do:
pawn Код:
public OnPlayerText( playerid, text[ ] )
{
if(IsNumeric(text))
{
new tmpvalue = strval( text );
printf( "%d", tmpvalue );
new string[ 156 ];
format( string, 155, "Written number: %d", tmpvalue );
SendClientMessage( playerid, COLOR_WHITE, string );
}
return false;
}
Get the IsNumeric command from the utils include.