GivePlayerWeapon (id) (weaponid) (ammo)
#1

Hi guys, who can help me to do "/giveplayerweapon" command using dcmd?
Reply
#2

Try this:

pawn Код:
dcmd_giveweapon(playerid, params[]){
    new weapon,ammo;
    if(sscanf(params,"ii",weapon,ammo)) return SendClientMessage(playerid,COLOR_GRAY,"USAGE: /giveweapon [weapon] [ammo]");
    GivePlayerWeapon(playerid, weapon, ammo);
    return 1;
}
List of weapon IDs: https://sampwiki.blast.hk/wiki/Weapons
Reply
#3

And what should i put under OnPlayerCommandText?
dcmd(giveweapon....??
Reply
#4

Quote:
Originally Posted by *******12
Посмотреть сообщение
And what should i put under OnPlayerCommandText?
dcmd(giveweapon....??
Put the code I posted somewhere in your script and when they do /giveweapon along with the weapon ID and ammo, it should give it to them.
Also, I used sscanf: https://sampforum.blast.hk/showthread.php?tid=120356

If you don't have this already, download that & put this at the top of your script:

pawn Код:
#include <sscanf2>
Reply
#5

Quote:
Originally Posted by *******12
Посмотреть сообщение
And what should i put under OnPlayerCommandText?
dcmd(giveweapon....??
Use the thing noles gave you, and put this under OnPlayerCommandText:
pawn Код:
dcmd(giveplayerweapon, 6, cmdtext);
Something like this.
I recommend you to use ZCMD, since it's a little easier.

and btw, you shouldn't make multiple threads about the same subject, just edit your last post with the message 'I want to use dcmd instead of strcmp'
Reply
#6

Not work, when i write /giveweapon,
Server unknown command
Reply
#7

pawn Код:
dcmd(giveplayerweapon, 16, cmdtext);
count..
WHYYYYYY DCMDDDDDDD :OOOOOOOOOOOOOOOO

YCMD is the best cmd processor, you're using methods from second world war -.-
I couldn't sleep if I use dcmd or strcmp :O
Reply
#8

work good with zcmds.
Reply
#9

ZCMD and YCMD are far more superior than DCMD and even easier as you don't have to do anything with OnPlayerCommandText - I recommend looking both up and chose the one you like the best.
Reply
#10

look

pawn Код:
YCMD:giveplayergun(playerid, params[], help)
{
      #pragma unused help
      new ammo, playa, playaname[MAX_PLAYER_NAME], admin[MAX_PLAYER_NAME], gun, string[128];
      if(!IsPlayerAdmin(playerid))
             return SendClientMessage(playerid, -1, "You are not allowed to use that command!");
      else if(sscanf(params, "uii", playa, gun))
             return SendClientMessage(playerid, -1, "CORRECT USAGE: /giveplayergun [playerid] [gun id] [ammo]");
      else if(playa == INVALID_PLAYER_ID))
             return SendClientMessage(playerid, -1, "ERROR: That player is not active");
      GivePlayerWeapon(playa, gun, ammo);
      GetPlayerName(playerid, admin, sizeof(admin));
      GetPlayerName(playa, playaname, sizeof(playaname));
      format(string, sizeof(string), "Admin %s gave you weapon ID %i", admin, gun);
      SendClientMessage(playa, -1, string);
      format(string, sizeof(string), "You gave gun (ID:%i) to %s(%d)", gun, playaname, playa);
      SendClientMessage(playerid, -1, string);
      return 1;
}
see
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)