Question about strval
#1

This is a quick question

if you use
Код:
val = strval(inputtext)
but if you enter words what happens


does the value equal 0 or does it do something else
Reply
#2

Do some tests and see what happens.
Reply
#3

alright I will try that, That was quick 5 seconds
Reply
#4

ok I created this command to test it it out but it would not compile the compiler keeps crashing

here is the command anything wrong with this

Код:
CMD:test(playerid,params[])
{
	if(IsPlayerAdmin(playerid))
	{
		new input[128];
		new string[128];
		new value;
		new name[128];
		if(sscanf(params,"s",input)
		{
		    return "SYNTAX /test [input]");
		}
  		GetPlayerName(playerid,name,sizeof(name));
		val = strval(input);
		format(string,128,"~TEST~[%s] has inputed %s and the value number is %i",inputtext,value);
		SendClientMessageToAll(DARKBLUE,string);
	}
	else
	{
	    SendClientMessage(playerid, RED, "ERROR");
	}
	return 1;
}
I know it is this command because I commented it out and it worked perfectly fine
Reply
#5

return "SYNTAX /test [input]"); ->> lol wtf?

do if(sscanf(params,"s",input)) return SendClientMessage(playeid, -1, "SYNTAX /test [input]");
Reply
#6

why "inputtext" its just input in the scmta
Reply
#7

[QUOTE=mastermax7777;2440754]return "SYNTAX /test [input]"); ->> lol wtf?

lol holey shit that is the stupidest mistake ever

well thanks
Reply
#8

wow I made more mistake then I thought should have looked closer but I am a lttlel clucker

c]:{
Reply
#9

Oh, in case you are wondering strval trims strings so you don't have to worry about whitespaces before and after value (strval(" 1304 ") == 1304)
Reply
#10

You can't return strings directly like that. You also can't return both integers and strings in the same function. But I guess you already discovered that.

For your strval question: if I remember correctly, it will return 0 if there are no numbers in the string. But it will return 15 when your input is "tysd15asdfae".
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)