Get some errors on my command
#1

I have tried to make a /createarmour wich you will need materials to create. But im getting errors now and cant find the problem.
Код:
C:\Users\new account\Desktop\Europe Roleplay\gamemodes\larp.pwn(70830) : error 003: declaration of a local variable must appear in a compound block
C:\Users\new account\Desktop\Europe Roleplay\gamemodes\larp.pwn(70830) : error 017: undefined symbol "price"
C:\Users\new account\Desktop\Europe Roleplay\gamemodes\larp.pwn(70830) : warning 215: expression has no effect
C:\Users\new account\Desktop\Europe Roleplay\gamemodes\larp.pwn(70830) : error 001: expected token: ";", but found "]"
C:\Users\new account\Desktop\Europe Roleplay\gamemodes\larp.pwn(70830) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
if(strcmp(cmd,"/createarmour",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pDealer])
            new price[MAX_PLAYERS]; //This is line 70830
            tmp = strtok(cmdtext, idx);
            giveplayerid = ReturnUser(tmp);
            if (IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(PlayerInfo[playerid][pMats] > 1999)
                    {
                        SafeSetPlayerArmour(giveplayerid, 100);
                        price[playerid] = 2000;
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        format(string, sizeof(string), "* %s hands an armour to %s.", sendername, giveplayer);
                        ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                        PlayerInfo[playerid][pMats] -= price[playerid];
                    }
                    else
                    {
                        SendClientMessage(playerid,COLOR_GREY,"** Not enough Materials for that Weapon!");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY,"** That player is not online!");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid,COLOR_GREY,"** You are not a Dealer!");
                return 1;
            }
        }
        return 1;
    }
Reply
#2

You haven't opened any braces after the if on line 70820
Reply
#3

Lol x) Thanks for telling me haha +REP (Y)
Reply
#4

when i type the command it say "that player is not online"
pawn Код:
if(strcmp(cmd,"/createarmour",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createarmour [playerid/PartOfName]");
                return 1;
            }
            if(PlayerInfo[playerid][pDealer])
            {
                new price[MAX_PLAYERS]; //This is line 70830
                tmp = strtok(cmdtext, idx);
                giveplayerid = ReturnUser(tmp);
                if (IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        if(PlayerInfo[playerid][pMats] > 1999)
                        {
                            SafeSetPlayerArmour(giveplayerid, 100);
                            price[playerid] = 2000;
                            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                            format(string, sizeof(string), "* %s hands an armour to %s.", sendername, giveplayer);
                            ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                            PlayerInfo[playerid][pMats] -= price[playerid];
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid,COLOR_GREY,"** Not enough materials to make the armour!");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY,"** That player is not online!");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid,COLOR_GREY,"** You are not a Dealer");
                return 1;
            }
        }
        return 1;
    }
Reply
#5

EDIT: sorry i saw wrong line.

What does the returnuser function do?
Reply
#6

How you mean?
Reply
#7

Could you please show your ReturnUser??
And you have done strtok twice when you have only single parameter to take from the command.
One just after the first player connected and the before the return user.
The second strtok would not give the playerid, the first one will.
Reply
#8

pawn Код:
if(strcmp(cmd,"/createarmour",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createarmour [playerid/PartOfName]");
                return 1;
            }
            if(PlayerInfo[playerid][pDealer])
            {
                new price[MAX_PLAYERS]; //This is line 70830
                tmp = strtok(cmdtext, idx);
                giveplayerid = ReturnUser(tmp);
                if (IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        if(PlayerInfo[playerid][pMats] > 1999)
                        {
                            SafeSetPlayerArmour(giveplayerid, 100);
                            price[playerid] = 2000;
                            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                            format(string, sizeof(string), "* %s hands an armour to %s.", sendername, giveplayer);
                            ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                            PlayerInfo[playerid][pMats] -= price[playerid];
                        }
                        else
                        {
                            SendClientMessage(playerid,COLOR_GREY,"** Not enough materials to make the armour!");
                            return 1;
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY,"** That player is not online!");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid,COLOR_GREY,"** You are not a Dealer");
                return 1;
            }
        }
        return 1;
    }
Try that, you had an else in the wrong place, if that doesn't work, show us your ReturnUser function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)