strcmp(cmdtext) problem
#1

pawn Код:
if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
    {
        if(PlayerInfo[playerid][pPcarkey] != 0)
        {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[256];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: fix(1-2)");
                return 1;
            }
            if(strcmp(x_nr,"fix1",true) == 0)
            {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                            if(SBizzInfo[8][sbProducts] == 0)
                            {
                                GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
                                return 1;
                            }
                            SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 1 was respawned !");
                            SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey]);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            SBizzInfo[8][sbTill] += 1000;
                            ExtortionSBiz(8, 1000);
                            SBizzInfo[8][sbProducts]--;
                            GivePlayerMoney(playerid, -1000);
                        }
                        else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
                    }
                    else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
                }
                if(strcmp(x_nr,"fix2",true) == 0)
                {
                if(!IsPlayerInAnyVehicle(playerid))
                        {
                            if(SBizzInfo[8][sbProducts] == 0)
                            {
                                GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
                                return 1;
                            }
                            SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 2 was respawned !");
                            SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey2]);
                            PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                            SBizzInfo[8][sbTill] += 1000;//towcar buisness
                            ExtortionSBiz(8, 1000);//ba codu e ok :|
                            SBizzInfo[8][sbProducts]--;
                            GivePlayerMoney(playerid, -1000);
                        }
                        else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
                    }
                    else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
                }
            }
A friend gave me this script to post here cuz he doesnt know english soo ermm the thing is that the error he gets is

Код:
undefined symbol: x_nr
On this line:
pawn Код:
if(strcmp(x_nr,"fix2",true) == 0)
Reply
#2

Rule N° 1: Do not copy shit from the godfather script. Now, if we were to properly indent the script, like this:
pawn Код:
if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
{
    if(PlayerInfo[playerid][pPcarkey] != 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[256];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: fix(1-2)");
                return 1;
            }
            if(strcmp(x_nr,"fix1",true) == 0)
            {
                if(!IsPlayerInAnyVehicle(playerid))
                {
                    if(SBizzInfo[8][sbProducts] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
                        return 1;
                    }
                    SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 1 was respawned !");
                    SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey]);
                    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                    SBizzInfo[8][sbTill] += 1000;
                    ExtortionSBiz(8, 1000);
                    SBizzInfo[8][sbProducts]--;
                    GivePlayerMoney(playerid, -1000);
                }
                else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
            }
            else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
        }
        if(strcmp(x_nr,"fix2",true) == 0)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                if(SBizzInfo[8][sbProducts] == 0)
                {
                    GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
                    return 1;
                }
                SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 2 was respawned !");
                SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey2]);
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                SBizzInfo[8][sbTill] += 1000;//towcar buisness
                ExtortionSBiz(8, 1000);//ba codu e ok :|
                SBizzInfo[8][sbProducts]--;
                GivePlayerMoney(playerid, -1000);
            }
            else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
        }
        else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
    }
}
We would clearly see that the fix2 structure is out of scope. Oops!
Reply
#3

So,what can i do to that command to work? I still don`t understant why is not working,because i made that like another command that i have,that is working,this not....
Reply
#4

If i left there just the FIX1 command ,is working like a charm,but if i add the fix2 command, it give`s that error right on that line with fix2 :

if(strcmp(x_nr,"fix2",true) == 0)
Reply
#5

else if(strcmp(x_nr,"fix2",true) == 0) ?
Reply
#6

East-oak, at first when i created the command /vehicle i tried to put like u said, but it is the same error
Reply
#7

Check if this works:
pawn Код:
if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
{
    if(PlayerInfo[playerid][pPcarkey] != 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr;
            if(sscanf(params, "d", x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: fix(1-2)");
                return 1;
            }
            if(x_nr != fix1 && x_nr != fix2)
            {
                SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
                SendClientMessage(playerid, COLOR_WHITE, "Available names: fix(1-2)");
                return 1;
            }
            if(x_nr == fix1)
            {
                if(!IsPlayerInAnyVehicle(playerid))
                {
                    if(SBizzInfo[8][sbProducts] == 0)
                    {
                        GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
                        return 1;
                    }
                    SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 1 was respawned !");
                    SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey]);
                    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                    SBizzInfo[8][sbTill] += 1000;
                    ExtortionSBiz(8, 1000);
                    SBizzInfo[8][sbProducts]--;
                    GivePlayerMoney(playerid, -1000);
                }
                else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
            }
            else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
        }
        if(x_nr == fix2)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                if(SBizzInfo[8][sbProducts] == 0)
                {
                    GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
                    return 1;
                }
                SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 2 was respawned !");
                SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey2]);
                PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                SBizzInfo[8][sbTill] += 1000;//towcar buisness
                ExtortionSBiz(8, 1000);//ba codu e ok :|
                SBizzInfo[8][sbProducts]--;
                GivePlayerMoney(playerid, -1000);
            }
            else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
        }
        else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
    }
}
Untested. I modified it with a similar command I use.
Reply
#8

This error gives me..

Quote:

C:\Users\Crouch\Desktop\FINAL\TESTE\gamemodes\blz. pwn(18235) : error 017: undefined symbol "params"
C:\Users\Crouch\Desktop\FINAL\TESTE\gamemodes\blz. pwn(18241) : error 017: undefined symbol "fix1"
C:\Users\Crouch\Desktop\FINAL\TESTE\gamemodes\blz. pwn(18247) : error 017: undefined symbol "fix1"
C:\Users\Crouch\Desktop\FINAL\TESTE\gamemodes\blz. pwn(1826 : error 017: undefined symbol "x_nr"

Reply
#9

ok hold on. Are you using ZCMD, DCMD?
Reply
#10

I fixed it,i just add IF isplayerconnect and i get only one error

CODE:
Quote:

if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)

if(PlayerInfo[playerid][pPcarkey] != 0)

if(IsPlayerConnected(playerid))
{
new x_nr;
new fix1;
new fix2;
if(sscanf(params, "d", x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
SendClientMessage(playerid, COLOR_WHITE, "Available names: fix(1-2)");
return 1;
}
if(x_nr != fix1 && x_nr != fix2)
{
SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
SendClientMessage(playerid, COLOR_WHITE, "Available names: fix(1-2)");
return 1;
}
if(IsPlayerConnected(playerid))
{
if(x_nr == fix1)
{
if(!IsPlayerInAnyVehicle(playerid))
{
if(SBizzInfo[8][sbProducts] == 0)
{
GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
return 1;
}
SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 1 was respawned !");
SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey]);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SBizzInfo[8][sbTill] += 1000;
ExtortionSBiz(8, 1000);
SBizzInfo[8][sbProducts]--;
GivePlayerMoney(playerid, -1000);
}
else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
}
else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
}
if(IsPlayerConnected(playerid))
{
if(x_nr == fix2)
{
if(!IsPlayerInAnyVehicle(playerid))
{
if(SBizzInfo[8][sbProducts] == 0)
{
GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
return 1;
}
SendClientMessage(playerid, COLOR_GRAD1,"{00C8FF}» {2641FE}PersonalCar 2 was respawned !");
SetVehicleToRespawn(PlayerInfo[playerid][pPcarkey2]);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
SBizzInfo[8][sbTill] += 1000;//towcar buisness
ExtortionSBiz(8, 1000);//ba codu e ok
SBizzInfo[8][sbProducts]--;
GivePlayerMoney(playerid, -1000);
}
else GameTextForPlayer(playerid, "~w~Car is~n~in ~r~use", 5000, 1);
}
else GameTextForPlayer(playerid, "~r~Not Enough Cash", 5000, 1);
}
}

ERROR:
Quote:

error 017: undefined symbol "params"

On this line:
Quote:

if(sscanf(params, "d", x_nr))

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)