PDA

View Full Version : give gun command (Help)


crukk11
12/02/2017, 11:17 AM
(Help) how to make command give gun but without id 38:confused::confused::confused::confused:

RyderX
12/02/2017, 11:27 AM
CMD:deserteagle(playerid,params[])
{
GivePlayerWeapon(playerid, 24);
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: http://wiki.sa-mp.com/wiki/Weapons

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

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:

CMD:sawnoff(playerid,params[])
{
GivePlayerWeapon(playerid,26);
return 1;
}


and same method as all weapons.

Eoussama
12/02/2017, 11:28 AM
This requires ZCMD , sscanf2 and formatex
ZCMD: http://forum.sa-mp.com/showthread.php?t=91354
formatex : http://forum.sa-mp.com/showthread.php?t=313488
sscanf2 :http://forum.sa-mp.com/showthread.php?t=570927


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

crukk11
12/02/2017, 11:31 AM
you right ryderx but my callback not work?

i dont no how to fix that

and eoussama how do you get formatex

Eoussama
12/02/2017, 11:33 AM
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

crukk11
12/02/2017, 11:35 AM
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"

Eoussama
12/02/2017, 11:37 AM
Download formatex, and put it in your include folder
pawno\include

crukk11
12/02/2017, 11:38 AM
can you give me the formatex.inc

i dont no how to compile it

RyderX
12/02/2017, 11:45 AM
http://pastebin.com/xMAMtB6M - formatex,

Paste it in Pawno>includes>[HERE IT WILL BE WITH ALL INCLUDES]

Eoussama
12/02/2017, 11:45 AM
can you give me the formatex.inc

i dont no how to compile it

You don't have to compile includes, just put in on your include folder and add this on your GM #include <formatex>

make sure the file extension of formatex is .inc

crukk11
12/02/2017, 11:47 AM
but it show amx file

TATIK
12/02/2017, 11:48 AM
This requires ZCMD , sscanf2 and formatex

why formatex ?

crukk11
12/02/2017, 11:50 AM
dont no

Eoussama
12/02/2017, 11:50 AM
why formatex ?

I'm too lazy to create a function that returns weapon names (depending on their ids)
so formatex saves time (%w)

crukk11
12/02/2017, 11:53 AM
ok. can you upload the formatex.inc to give to me pls

crukk11
12/02/2017, 12:08 PM
who can give me a command give gun without rcon login and id 38
zcmd

RyderX
12/02/2017, 12:40 PM
Command Officially Posted By Eoussama and Edited By RyderX:

CMD:givegun(playerid, params[]){
new wid, ammo, str[128], pName[MAX_PLAYER_NAME];
if(sscanf(params, "ui", wid, ammo)) return SendClientMessage(playerid, -1, "USAGE: /givegun [weapon id] [ammo]");
if(wid == 38) return SendClientMessage(playerid, 0xFF0000, "ERROR: weapond id 38 is forbidden");
GetPlayerName(playerid, pName, sizeof(pName));
GivePlayerWeapon(playerid, wid, ammo);
format(string,sizeof(string),"You got Weapon ID i%",wid);
SendClientMessage(playerid, 0xf8f8f8fff, string);
return 1;
}

crukk11
12/02/2017, 12:42 PM
i get this

C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : error 017: undefined symbol "string"
C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : error 017: undefined symbol "string"
C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : error 029: invalid expression, assumed zero
C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : fatal error 107: too many error messages on one line

RyderX
12/02/2017, 12:49 PM
i get this

C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : error 017: undefined symbol "string"
C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : error 017: undefined symbol "string"
C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : error 029: invalid expression, assumed zero
C:\Users\Cyber\Desktop\New folder\gamemodes\GL.pwn(1941) : fatal error 107: too many error messages on one line

Try now

CMD:givegun(playerid, params[]){
new wid, ammo, str[128], pName[MAX_PLAYER_NAME];
if(sscanf(params, "ui", wid, ammo)) return SendClientMessage(playerid, -1, "USAGE: /givegun [weapon id] [ammo]");
if(wid == 38) return SendClientMessage(playerid, 0xFF0000, "ERROR: weapond id 38 is forbidden");
GetPlayerName(playerid, pName, sizeof(pName));
GivePlayerWeapon(playerid, wid, ammo);
format(str,sizeof(str),"You got Weapon ID %i",wid);
SendClientMessage(playerid, 0xf8f8f8fff, str);
return 1;
}

crukk11
12/02/2017, 12:51 PM
i will test

crukk11
12/02/2017, 01:03 PM
it work when compile but when i start the server it crash