Variable - 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: Variable (
/showthread.php?tid=453011)
Variable -
deimantas1 - 23.07.2013
Hello, I want make IF. That if is 0, wrote one text, if is more than 0 wrote next text. And my code:
Код:
CMD:t1(playerid,params[])
{
masinike[playerid]=400;
new string[6]="v";
strcat(string,masinike[playerid]);
if(string==0)
{
SendClientMessage(playerid,RAUDONA,"No units.");
}
else
{
new msg[15];
format(msg,sizeof(msg),"Is units: %d",string);
SendClientMessage(playerid,RAUDONA,msg);
}
return 1;
}
Error:
Код:
error 033: array must be indexed (variable "string")
Re: Variable -
Sinner - 23.07.2013
pawn Код:
CMD:t1(playerid,params[])
{
masinike[playerid] = 400; // No idea why you do this, since it will always evaluate the next IF as false
if(masinike[playerid] == 0)
{
SendClientMessage(playerid,RAUDONA,"No units.");
}
else
{
new msg[24];
format(msg,sizeof(msg),"Is units: v%d", masinike[playerid]);
SendClientMessage(playerid,RAUDONA,msg);
}
return 1;
}
Re: Variable -
Aliassassin123456 - 23.07.2013
pawn Код:
CMD:t1(playerid,params[])
{
masinike[playerid]=400;
new string[6];
new str[128];
format(str,128,"v%d",masinike[playerid]);
strmid(string,str,0,strlen(str),6);
if(string[0] == "v" && string[1] == 0)
{
SendClientMessage(playerid,RAUDONA,"No units.");
}
else
{
new msg[15];
format(msg,sizeof(msg),"Is units: %s",string);
SendClientMessage(playerid,RAUDONA,msg);
}
return 1;
}
sorry when i typing you post a reply Sinner
Re: Variable -
deimantas1 - 23.07.2013
I want join string "v" with variable number.
Re: Variable -
MP2 - 23.07.2013
Quote:
Originally Posted by deimantas1
I want join string "v" with variable number.
|
That makes no sense.
Re: Variable -
deimantas1 - 23.07.2013
I want that combining the letter "v" with the value of the variable, in this case the number of 400th Get a V400 and it would be a variable which is created above gamemode. This variable is the value of units.