PDA

View Full Version : Variable


deimantas1
23/07/2013, 02:35 PM
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")

Sinner
23/07/2013, 02:41 PM
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;
}

Aliassassin123456
23/07/2013, 02:44 PM
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 :mad: :D

deimantas1
23/07/2013, 03:08 PM
I want join string "v" with variable number.

MP2
23/07/2013, 03:09 PM
I want join string "v" with variable number.
That makes no sense.

deimantas1
23/07/2013, 03:12 PM
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.