SA-MP Forums Archive
Give Weapon 2 errors and 1 warmning - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Give Weapon 2 errors and 1 warmning (/showthread.php?tid=242687)



Give Weapon 2 errors and 1 warmning - ricardo178 - 20.03.2011

Hey guys... I was making my give weapon cmd and i get this erros:
Код:
C:\Users\Ricardo\Desktop\Mini-DM\Mini-DM\Freedoom\filterscripts\adminric.pwn(816) : error 029: invalid expression, assumed zero
C:\Users\Ricardo\Desktop\Mini-DM\Mini-DM\Freedoom\filterscripts\adminric.pwn(818) : error 029: invalid expression, assumed zero
C:\Users\Ricardo\Desktop\Mini-DM\Mini-DM\Freedoom\filterscripts\adminric.pwn(836) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
On this code:
pawn Код:
COMMAND:giveweapon(playerid, params[])
{
    new id;
    new weap;
    new ammo;
    if(IsPlayerConnected(id))
    {
        if(PlayerInfo[playerid][AdminLevel] >= 106)
        {
            if(!sscanf(params, "uii", id, weap, ammo))
            {
                if((weap >= 1 && weap <= 46)
                {
                    if((ammo >= 1 && ammo <= 5000)
                    {
                        new string[64];
                        new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, name, sizeof(name));
                        GetPlayerName(id, PlayerName, sizeof(PlayerName));
                        format(string, sizeof(string), "%s has given You weapon %d with %d ammu.", name, weap, ammo);
                        SendClientMessage(id, 0xFF00CC, string);
                        format(string, sizeof(string), "You gave weapon %d with %d ammu to %s .", weap, ammo, PlayerName);
                        SendClientMessage(playerid, 0xFF00CC, string);
                        GivePlayerWeapon(id, weap, ammo);
                        return 1;
                    }
                    else return SendClientMessage(playerid, 0xFF00CC, "Max. Ammo is 5000");
                }
                else return SendClientMessage(playerid, 0xFF00CC, "Invalid weapon id!");

            }
            else return SendClientMessage(playerid, 0xFF00CC, "USAGE: /giveweapon[PlayerId/PartOfName] [WeaponId] [Ammo]");
            SendClientMessage(playerid, 0xFF00CC, "1(Brass) 2(Nite) 3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 9(Chainsaw) 10-13(Dildo)");
            SendClientMessage(playerid, 0xFF00CC, "14(Flowers) 15(Cane) 16(Grenades) 17(Teargas) 18(Molotovs) 22(Pistol) 23(SPistol) 24(Eagle)");
            SendClientMessage(playerid, 0xFF00CC, "25(Shotgun) 26(sawn-off) 27(Combat) 28(TEC9) 29(MP5) 30(AK47) 31(M4) 32(MAC10) 33(Country)");
            SendClientMessage(playerid, 0xFF00CC, "34(Sniper) 35(RPG) 37(Flamethrower) 38(Minigun) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
            return 1;
        }
        else return SendClientMessage(playerid, 0xFF00CC, "You are not allowed to use this command.");
    }
    else return SendClientMessage(playerid, 0xFF00CC, "Player Is Not Connected");
}
Error lines:
816:
pawn Код:
if((weap >= 1 && weap <= 46)
818:
pawn Код:
if((ammo >= 1 && ammo <= 5000)
836:
pawn Код:
SendClientMessage(playerid, 0xFF00CC, "1(Brass) 2(Nite) 3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 9(Chainsaw) 10-13(Dildo)");
THANKS


Re: Give Weapon 2 errors and 1 warmning - Zh3r0 - 20.03.2011

Change:
pawn Код:
if((weap >= 1 && weap <= 46)
                {
                    if((ammo >= 1 && ammo <= 5000)
                    {
To:
pawn Код:
if(weap >= 1 && weap <= 46)
                {
                    if(ammo >= 1 && ammo <= 5000)
                    {
And Change:
pawn Код:
else return SendClientMessage(playerid, 0xFF00CC, "USAGE: /giveweapon[PlayerId/PartOfName] [WeaponId] [Ammo]");
            SendClientMessage(playerid, 0xFF00CC, "1(Brass) 2(Nite) 3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 9(Chainsaw) 10-13(Dildo)");
            SendClientMessage(playerid, 0xFF00CC, "14(Flowers) 15(Cane) 16(Grenades) 17(Teargas) 18(Molotovs) 22(Pistol) 23(SPistol) 24(Eagle)");
            SendClientMessage(playerid, 0xFF00CC, "25(Shotgun) 26(sawn-off) 27(Combat) 28(TEC9) 29(MP5) 30(AK47) 31(M4) 32(MAC10) 33(Country)");
            SendClientMessage(playerid, 0xFF00CC, "34(Sniper) 35(RPG) 37(Flamethrower) 38(Minigun) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
to
pawn Код:
else return SendClientMessage(playerid, 0xFF00CC, "USAGE: /giveweapon[PlayerId/PartOfName] [WeaponId] [Ammo]"),
            SendClientMessage(playerid, 0xFF00CC, "1(Brass) 2(Nite) 3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 9(Chainsaw) 10-13(Dildo)"),
            SendClientMessage(playerid, 0xFF00CC, "14(Flowers) 15(Cane) 16(Grenades) 17(Teargas) 18(Molotovs) 22(Pistol) 23(SPistol) 24(Eagle)"),
            SendClientMessage(playerid, 0xFF00CC, "25(Shotgun) 26(sawn-off) 27(Combat) 28(TEC9) 29(MP5) 30(AK47) 31(M4) 32(MAC10) 33(Country)"),
            SendClientMessage(playerid, 0xFF00CC, "34(Sniper) 35(RPG) 37(Flamethrower) 38(Minigun) 41(spray) 42(exting) 43(Camera) 46(Parachute)");



Re: Give Weapon 2 errors and 1 warmning - Mean - 20.03.2011

pawn Код:
if(weap >= 1 && weap <= 46)
pawn Код:
if(ammo >= 1 && ammo <= 5000)
and
pawn Код:
else SendClientMessage(playerid, 0xFF00CC, "USAGE: /giveweapon[PlayerId/PartOfName] [WeaponId] [Ammo]");
EDIT: Slow..


Re: Give Weapon 2 errors and 1 warmning - Mauzen - 20.03.2011

Line 816/818: Check the amount of brackets that you open against the amount you close.

Line 836:
pawn Код:
else return SendClientMessage(playerid, 0xFF00CC, "USAGE: /giveweapon[PlayerId/PartOfName] [WeaponId] [Ammo]");
            SendClientMessage(playerid, 0xFF00CC, "1(Brass) 2(Nite) 3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 9(Chainsaw) 10-13(Dildo)");
            SendClientMessage(playerid, 0xFF00CC, "14(Flowers) 15(Cane) 16(Grenades) 17(Teargas) 18(Molotovs) 22(Pistol) 23(SPistol) 24(Eagle)");
            SendClientMessage(playerid, 0xFF00CC, "25(Shotgun) 26(sawn-off) 27(Combat) 28(TEC9) 29(MP5) 30(AK47) 31(M4) 32(MAC10) 33(Country)");
            SendClientMessage(playerid, 0xFF00CC, "34(Sniper) 35(RPG) 37(Flamethrower) 38(Minigun) 41(spray) 42(exting) 43(Camera) 46(Parachute)");
You already return after the first sendclientmessage, so there is no chance for the other lines to get called. Move the return and add bglock brackets to assign all lines to the else.
pawn Код:
else { //changed this line
            SendClientMessage(playerid, 0xFF00CC, "USAGE: /giveweapon[PlayerId/PartOfName] [WeaponId] [Ammo]");
            SendClientMessage(playerid, 0xFF00CC, "1(Brass) 2(Nite) 3(Club) 4(knife) 5(bat) 6(Shovel) 7(Cue) 8(Katana) 9(Chainsaw) 10-13(Dildo)");
            SendClientMessage(playerid, 0xFF00CC, "14(Flowers) 15(Cane) 16(Grenades) 17(Teargas) 18(Molotovs) 22(Pistol) 23(SPistol) 24(Eagle)");
            SendClientMessage(playerid, 0xFF00CC, "25(Shotgun) 26(sawn-off) 27(Combat) 28(TEC9) 29(MP5) 30(AK47) 31(M4) 32(MAC10) 33(Country)");
            return SendClientMessage(playerid, 0xFF00CC, "34(Sniper) 35(RPG) 37(Flamethrower) 38(Minigun) 41(spray) 42(exting) 43(Camera) 46(Parachute)"); // changed this line
} //And added this



Re: Give Weapon 2 errors and 1 warmning - ricardo178 - 20.03.2011

Thanks very much!