03.03.2013, 16:56
Hi guys, who can help me to do "/giveplayerweapon" command using dcmd?
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;
}
And what should i put under OnPlayerCommandText?
dcmd(giveweapon....?? |
#include <sscanf2>
And what should i put under OnPlayerCommandText?
dcmd(giveweapon....?? |
dcmd(giveplayerweapon, 6, cmdtext);
dcmd(giveplayerweapon, 16, cmdtext);
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;
}