SA-MP Forums Archive
/giveweapon command - 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)
+--- Thread: /giveweapon command (/showthread.php?tid=526196)



/giveweapon command - saffierr - 16.07.2014

I need help with this command

I want that if a admin types /giveweapon that he can gives a weapon to a random player.
and also I want as USAGE "USAGE:/Giveweapon [ID] [IDofWeapon] [AMOUNT]"
Just take my code and improve it
Quote:

CMD:giveweapon(playerid, params[])
{
if (!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "SERVER: Unknown command.");
}
else if (IsPlayerAdmin(playerid))
{
GivePlayerWeapon(playerid, weaponid, 6000);
}
if (!IsPlayerLoggedIn(playerb))
{
SendClientMessage(playerid, COLOR_WARN, "Invalid player id");
}
if (weapon < 4 || weapon > 41)
{
SendClientMessage(playerid, COLOR_WARN, "Weapons are between id 4 and 41");
}
return 1;
}




Re: /giveweapon command - BlackSirrah239 - 16.07.2014

Quote:
Originally Posted by saffierr
Посмотреть сообщение
I need help with this command

I want that if a admin types /giveweapon that he can gives a weapon to a random player.
and also I want as USAGE "USAGE:/Giveweapon [ID] [IDofWeapon] [AMOUNT]"
Just take my code and improve it
Refer back to this thread - https://sampforum.blast.hk/showthread.php?tid=526187
Both Miguel and I showed you how to use sscanf. Try using it yourself here, as we aren't here to do all your commands for you. Try your best to get it to work with sscanf and come back here if you need more help.


Re: /giveweapon command - saffierr - 16.07.2014

dude I already have sscanf...


Re: /giveweapon command - amirab - 16.07.2014

How about this?
PHP код:
CMD:giveweap(playeridparams[])
{
    new 
idweap ammo;
       
    else if (
sscanf(params"udd"idweap ammo))
        
SendClientMessage(playerid, -1"USAGE: /giveweap [ playerid ] [ weaponid ] [ ammo ]");
       
    else if (
id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"Player Is Not Connected!");
        
       
    else
    {
        
GivePlayerWeapon(id weap ammo)
        
SendClientMessage(playeridCOLOR_GREEN"You Gave A Gun To A Player.");
    }
    return 
1;

and something that you need Please Please
before making a thread just go to ****** and search anything that you want

And don't forget my +REP