pawn Code:
COMMAND:giveweapon(playerid, params[])
{
new target, weapon, amount;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: You need to login first before using any command.");
if(sscanf(params, "udd", target, amount))
{
SCM(playerid, GREY, "[Parameters]: /give [option] [playerid] [amount]");
SCM(playerid, COLOR_FADE1, "[Options]: weapon | weed");
return 1;
}
if(!strcmp(params, "weapon", true))
{
if(target == playerid) return SCM(playerid, COLOR_GREY, "SERVER: You can't give it to yourself.");
if(IsPlayerConnected(target))
{
if(IsPlayerNearPlayer(playerid, target, 1))
{
if(sscanf(params, "udd", target, amount)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /give weapon [playerid] [weapon] [amount]");
new string[128];
format(string, sizeof(string), "%s has given you a %s with %d ammo.", RPN(playerid), RWN(GetPlayerWeapon(playerid)), GetPlayerAmmo(playerid));
SCM(target, COLOR_NEWBLUE, string);
format(string, sizeof(string), "You have given %s a %s with %d ammo.", RPN(target), RWN(GetPlayerWeapon(playerid)), GetPlayerAmmo(playerid));
SCM(playerid, COLOR_NEWBLUE, string);
format(string, sizeof(string), "%s glances towards %s as he gives him/her something.", RPN(playerid), RPN(target));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 15.0, 5000);
SetPlayerFacingPlayer(playerid, target);
ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
ApplyAnimation(target,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
GivePlayerWeapon(target, weapon, amount);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, "SERVER: You are too far away from that player.");
return 1;
}
}
}
if(strcmp(params, "weed", true))
{
new wAmount;
new tArget;
if(IsPlayerLoggedIn(playerid))
{
SCM(playerid, GREY, "You are not logged in!");
return 1;
}
new Str[128];
else if(sscanf(params, "ud", tArget, wAmount)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /give weed [playerid] [amount]");
else if(PlayerInfo[playerid][pWeed] < wAmount) return SendClientMessage(playerid, COLOR_GREY, "SERVER: You don't have that much weed.");
PlayerInfo[playerid][pWeed] -= wAmount;
PlayerInfo[target][pWeed] += wAmount;
format(Str, sizeof(Str), "NOTE: %s has given you a %d grams of weed.", RPN(playerid), wAmount);
SCM(target, COLOR_LIGHTBLUE, Str);
format(Str, sizeof(Str), "NOTE: You have given %s, %d grams of weed.", RPN(target), wAmount);
SCM(playerid, COLOR_LIGHTBLUE, Str);
format(Str, sizeof(Str), "%s glances towards %s as he gives him/her something.", RPN(playerid), RPN(tArget));
SendNearbyMessage(playerid, 15, Str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetPlayerChatBubble(playerid, Str, COLOR_PURPLE, 15.0, 5000);
SetPlayerFacingPlayer(playerid, tArget);
ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
ApplyAnimation(tArget,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
}
return 1;
}