SA-MP Forums Archive
GiveAllweapon - 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: GiveAllweapon (/showthread.php?tid=243076)



GiveAllweapon - Snipa - 21.03.2011

pawn Код:
CMD:giveallweapon(playerid,params[])
{
    if(PInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid)) {
        new Weap,WeapName[25], ammo, name[MAX_PLAYER_NAME], string[50];
        if(sscanf(params,"si",Weap, ammo)) return SendClientMessage(playerid,RED,"Usage: /giveallweapon [weapon name] [ammo]");
        if(!IsValidWeapon(Weap)) return SendClientMessage(playerid,RED,"ERROR: Invalid weapon ID");
        ACMDM(playerid,"GIVEALLWEAPON");
        foreach(Player, i)
        {
            PlayerPlaySound(i,1057,0.0,0.0,0.0);
            GivePlayerWeapon(i,GetWeaponIDFromName(Weap),ammo);
        }
        GetWeaponName(Weap,WeapName,25); //3029
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"Administrator %s has given all players weapon: %s with %d ammo",name,WeapName,ammo);
        SendClientMessageToAll(blue,string);
    }
    else SendClientMessage(playerid,RED,"You are not a high enough level to use this command");
    return 1;
}
Agh got to go to school. Well it says argument mismatch at line 3029. Thanks.


Re: GiveAllweapon - Vince - 21.03.2011

I suppose this function accepts a string, but you've declared it as in integer:

GetWeaponIDFromName(Weap)


Re: GiveAllweapon - Snipa - 21.03.2011

Quote:
Originally Posted by Vince
Посмотреть сообщение
I suppose this function accepts a string, but you've declared it as in integer:

GetWeaponIDFromName(Weap)
pawn Код:
CMD:giveallweapon(playerid,params[])
{
    if(PInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid)) {
        new Weap,WeapID[20], ammo, name[MAX_PLAYER_NAME], string[128];
        if(sscanf(params,"si",Weap, ammo)) return SendClientMessage(playerid,RED,"Usage: /giveallweapon [weapon name] [ammo]");
        if(!IsValidWeapon(Weap)) return SendClientMessage(playerid,RED,"ERROR: Invalid weapon ID");
        ACMDM(playerid,"GIVEALLWEAPON");
        GetWeaponIDFromName(Weap,WeapID,20); //3024
        foreach(Player, i)
        {
            PlayerPlaySound(i,1057,0.0,0.0,0.0);
            GivePlayerWeapon(i,WeapID,ammo); //3028
        }
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"Administrator %s has given all players weapon: %s with %d ammo",name,Weap,ammo);
        SendClientMessageToAll(blue,string);
    }
    else return SendClientMessage(playerid,RED,"You are not a high enough level to use this command");
    return 1;
}
Changed it a bit and now I get

pawn Код:
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(3024) : error 035: argument type mismatch (argument 1)
C:\Users\Chris\Documents\Serv\Server\gamemodes\COS.pwn(3028) : error 035: argument type mismatch (argument 2)



Re: GiveAllweapon - Jefff - 22.03.2011

pawn Код:
CMD:giveallweapon(playerid,params[])
{
    if(PInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid)) {
        new Weap[24],WeapID, ammo, name[MAX_PLAYER_NAME], string[128];
        if(sscanf(params,"s[24]i",Weap, ammo)) return SendClientMessage(playerid,RED,"Usage: /giveallweapon [weapon name] [ammo]");
        if(!IsValidWeapon(Weap)) return SendClientMessage(playerid,RED,"ERROR: Invalid weapon ID");
        ACMDM(playerid,"GIVEALLWEAPON");
        WeapID = GetWeaponIDFromName(Weap); //3024
        foreach(Player, i)
        {
            PlayerPlaySound(i,1057,0.0,0.0,0.0);
            GivePlayerWeapon(i,WeapID,ammo); //3028
        }
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"Administrator %s has given all players weapon: %s with %d ammo",name,Weap,ammo);
        SendClientMessageToAll(blue,string);
    }
    else return SendClientMessage(playerid,RED,"You are not a high enough level to use this command");
    return 1;
}



Re: GiveAllweapon - Snipa - 22.03.2011

The IsValidWeapon had an argument mismatch.. when I take it out it compiles fine.


Re: GiveAllweapon - Jefff - 22.03.2011

So give
pawn Код:
WeapID = GetWeaponIDFromName(Weap); //3024
if(!IsValidWeapon(WeapID)) return SendClientMessage(playerid,RED,"ERROR: Invalid weapon ID");
ACMDM(playerid,"GIVEALLWEAPON");



Re: GiveAllweapon - Snipa - 22.03.2011

Thanks.