SA-MP Forums Archive
strval inputtext - 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)
+--- Thread: strval inputtext (/showthread.php?tid=665084)



strval inputtext - Kevinas100 - 21.03.2019

PHP Code:
             if(response)
             {
                 new 
zin[222];
                if(
strval(inputtext) > 128) return SendClientMessage(playerid, -1"{f03333}Tekstas per ilgas!");
                if(
GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, -1"{f03333}Neturite pakankamai pinigų!");
                
format(zin,sizeof(zin),"{ff6699}[{ff99cc}SKELBIMAS ] %s{ff6699}{ff99cc}: %s",GET_NAME(playerid),strval(inputtext));
                
SendClientMessageToAll(0xffcc00FF,zin);
                
format(zin,sizeof(zin),"{ff6699} %s",strval(inputtext));
                   
SendClientMessageToAll(-1zin);
                
GivePlayerMoneyA(playerid,-500);
                   
SendClientMessage(playerid, -1"Sumokėjote 500$");
             } 
it doesn't show the text, what could be the problem


Re: strval inputtext - Sasino97 - 21.03.2019

Strval returns an integer, so you should change %s to %d


Re: strval inputtext - Kevinas100 - 21.03.2019

Quote:
Originally Posted by Sasino97
View Post
Strval returns an integer, so you should change %s to %d
how should I make it return a string?


Re: strval inputtext - Shaneisace - 21.03.2019

Quote:
Originally Posted by Kevinas100
View Post
how should I make it return a string?
Just remove strval() around the "inputtext" that'll keep it as a string

Strval converts a string into a integer value.

Code:
format(zin,sizeof(zin),"{ff6699}[{ff99cc}SKELBIMAS ] %s{ff6699}{ff99cc}: %s" ,GET_NAME(playerid), inputtext); 
SendClientMessageToAll(0xffcc00FF,zin); 
format(zin,sizeof(zin),"{ff6699} %s", inputtext);
Also use "strlen" for the character count.

Code:
if(strlen(inputtext) > 128) return SendClientMessage(playerid, -1, "{f03333}Tekstas per ilgas!");



Re: strval inputtext - Kevinas100 - 21.03.2019

Quote:
Originally Posted by Shaneisace
View Post
Just remove strval() around the "inputtext" that'll keep it as a string

Strval converts a string into a integer value.

Code:
format(zin,sizeof(zin),"{ff6699}[{ff99cc}SKELBIMAS ] %s{ff6699}{ff99cc}: %s" ,GET_NAME(playerid), inputtext); 
SendClientMessageToAll(0xffcc00FF,zin); 
format(zin,sizeof(zin),"{ff6699} %s", inputtext);
Also use "strlen" for the character count.

Code:
if(strlen(inputtext) > 128) return SendClientMessage(playerid, -1, "{f03333}Tekstas per ilgas!");
alright, thank you