SA-MP Forums Archive
give gun command (Help) - 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: give gun command (Help) (/showthread.php?tid=628618)



give gun command (Help) - crukk11 - 12.02.2017

(Help) how to make command give gun but without id 38


Re: give gun command (Help) - RyderX - 12.02.2017

PHP код:
CMD:deserteagle(playerid,params[])
{
     
GivePlayerWeapon(playerid24);
     return 
1;

It's not necessary to include Minigun id to give all weapons, you can simply use

GivePlayerWeapon(playerid, weaponid);

Under a Command or a callback,

You can get Weapons IDs From here: https://sampwiki.blast.hk/wiki/Weapons

For example, We want to get sawn-off shotgun, what should we do?

PHP код:
CMD:mycommand(playerid,params[])
{
     
//do something here
     
return 1;

ok Now we have to give player sawn off, Sawn-off id is 26, so we have to type like this:

PHP код:
CMD:sawnoff(playerid,params[])

      
GivePlayerWeapon(playerid,26);
      return 
1;

and same method as all weapons.


Re: give gun command (Help) - Eoussama - 12.02.2017

This requires ZCMD , sscanf2 and formatex
ZCMD: https://sampforum.blast.hk/showthread.php?tid=91354
formatex : https://sampforum.blast.hk/showthread.php?tid=313488
sscanf2 :https://sampforum.blast.hk/showthread.php?tid=570927
PHP код:

CMD
:givegun(playeridparams[]){
    new 
pidwidammostr[128], pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME];
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF0000"ERROR: You can't use this command");
    if(
sscanf(params"uii"pidwidammo)) return SendClientMessage(playerid, -1"USAGE: /givegun [player id] [weapon id] [ammo]");
    if(!
IsPlayerConnected(pid)) return SendClientMessage(playerid0xFF0000"ERROR: Player is not cnnected");
    if(
wid == 38) return SendClientMessage(playerid0xFF0000"ERROR: weapond id 38 is forbidden");
    
GetPlayerName(playeridpNamesizeof(pName));
    
GetPlayerName(pidtNamesizeof(tName));
    
GivePlayerWeapon(pidwidammo);
    
format(strsizeof(str), "Administrator %s has given %s %w with %d ammo",pNametNamewidammo);
    
SendClientMessageToAll(0xFF00FFstr);
    return 
1;




Re: give gun command (Help) - crukk11 - 12.02.2017

you right ryderx but my callback not work?

i dont no how to fix that

and eoussama how do you get formatex


Re: give gun command (Help) - Eoussama - 12.02.2017

Quote:
Originally Posted by crukk11
Посмотреть сообщение
you right ryderx but my callback not work?

i dont no how to fix that

and eoussama how do you get formatex
check the link I provided there, it has the download link and all instructions


Re: give gun command (Help) - crukk11 - 12.02.2017

when i compile i got this error

C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(6) : fatal error 100: cannot read from file: "formatex"


Re: give gun command (Help) - Eoussama - 12.02.2017

Download formatex, and put it in your include folder
pawno\include


Re: give gun command (Help) - crukk11 - 12.02.2017

can you give me the formatex.inc

i dont no how to compile it


Re: give gun command (Help) - TATIK - 12.02.2017

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
This requires ZCMD , sscanf2 and formatex
why formatex ?


Re: give gun command (Help) - Eoussama - 12.02.2017

Quote:
Originally Posted by TATIK
Посмотреть сообщение
why formatex ?
I'm too lazy to create a function that returns weapon names (depending on their ids)
so formatex saves time (%w)