Variable
#1

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")
Reply
#2

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;
}
Reply
#3

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
Reply
#4

I want join string "v" with variable number.
Reply
#5

Quote:
Originally Posted by deimantas1
Посмотреть сообщение
I want join string "v" with variable number.
That makes no sense.
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)