SA-MP Forums Archive
strval(inputtext) Leaves no message - 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: strval(inputtext) Leaves no message (/showthread.php?tid=182831)



[SOLVED] strval(inputtext) Leaves no message - spyr0x - 12.10.2010

I have a problem with the /kick command where the message from ( strval(inputtext) ) wont show.

Here is the code to open the dialog:
Код:
ShowPlayerDialog(playerid, 005, DIALOG_STYLE_INPUT, "Kick", "Please enter the reason.", "Kick", "Cancel");
And here is the dialog code:
Код:
	if(dialogid == 005)
	{
	    if(!response) {
	    }
	    else {
		new vname[MAX_PLAYER_NAME];
		new vname2[MAX_PLAYERS];
		new pname[MAX_PLAYER_NAME];
		new string[256];
		GetPlayerName(inputid[playerid], vname, sizeof(vname));
		format(vname2[playerid], 128, "%s", vname);
		if(victim[playerid] == vname2[playerid]) {
		GetPlayerName(playerid, pname, sizeof(pname));
		format(string,sizeof(string),"[PN-Admin] Player %s [%d] was kicked by admin %s.",victim[playerid], inputid[playerid], pname);
		SendClientMessageToAll(red, string);
		format(string,sizeof(string),"[PN-Admin] Reason: %s.",strval(inputtext));
		SendClientMessageToAll(red, string);
		//Kick(inputid[playerid]);
                victim[playerid] = -1;
		inputid[playerid] = -1;
		vname2[playerid] = -1;
		}
		else {
		format(string,sizeof(string),"[PN-Admin] Player %s [%d] has disconnected.",victim[playerid], inputid[playerid]);
		SendClientMessage(playerid, orange, string);
		inputid[playerid] = -1;
		victim[playerid] = -1;
		vname2[playerid] = -1;
		}
	    }
	}
The message thats going to show the ( strval(inputtext) ) is this:
Код:
format(string,sizeof(string),"[PN-Admin] Reason: %s.",strval(inputtext));
SendClientMessageToAll(red, string);
Please help me solve the problem.

Thanks.


Re: strval(inputtext) Leaves no message - Grim_ - 12.10.2010

Код:
format(string,sizeof(string),"[PN-Admin] Reason: %d.",strval(inputtext));
This forum requires that you wait 120 seconds between posts. Please try again in 20 seconds.


Re: strval(inputtext) Leaves no message - spyr0x - 12.10.2010

Quote:
Originally Posted by Grim_
Посмотреть сообщение
Код:
format(string,sizeof(string),"[PN-Admin] Reason: %d.",strval(inputtext));
This leaves only the number 0 as a reason. It's supposed that the kick reason admin made in the dialog will show.


Re: strval(inputtext) Leaves no message - Grim_ - 12.10.2010

You have the wrong function then, strval turns the string into an integer.

Simply do:
Код:
format(string,sizeof(string),"[PN-Admin] Reason: %s.",inputtext);



Re: strval(inputtext) Leaves no message - spyr0x - 12.10.2010

Problem solved, thanks Grim!


Re: strval(inputtext) Leaves no message - Zeex - 12.10.2010

If reason is not a number why do you strval it?

Edit: ah too late, damn new forum


Re: strval(inputtext) Leaves no message - Niixie - 13.10.2010

Quote:
Originally Posted by Grim_
Посмотреть сообщение
You have the wrong function then, strval turns the string into an integer.

Simply do:
Код:
format(string,sizeof(string),"[PN-Admin] Reason: %s.",inputtext);
I were just about to tell.
-If you have a string, you dont have to do anything with it, when you want to show it with %s