Any idea why /giveweapon is not working? -
darkhunter332 - 22.05.2017
Код:
CMD:giveweapon(playerid, params[])
{
new string[128], playerb, weapon;
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
if(sscanf(params, "us[32]d", playerb, weapon))
{
SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /giveweapon [playerid] [weapon]");
return 1;
}
Whenever i try to give someone a weapon, It says you're away, I tried to change between stuff, Any idea?
Re: Any idea why /giveweapon is not working? -
FireRage007 - 22.05.2017
See bro i am a beginner but the line
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
Gives me a sensation that it can be used if you are near to that player. Do you do that standing nearby to the player?
Sorry if said wrong :P
Re: Any idea why /giveweapon is not working? -
darkhunter332 - 22.05.2017
Basicly, It should work if the player is nearby, the command of course.
Here's an example of one of the weapons
Код:
else if(!strcmp(params, "bat", true, 3))
{
if(GetPlayerWeapon(playerid) != 5) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon.");
RemovePlayerWeapon(playerid, 5);
GiveDodWeapon(playerb, 5, 99999);
format(string, sizeof(string), " You have given %s your %d.", RPN(playerb),weapon);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), " %s has given you %d.", RPN(playerid), weapon);
SendClientMessage(playerb, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s takes out a gun and hands it to %s.", RPN(playerid), RPN(playerb));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
Re: Any idea why /giveweapon is not working? -
rolex - 22.05.2017
First step, what's the purpose of that command? remove weapon from
playerid and give it to
playerb? or only give weapon to player like admin?
Re: Any idea why /giveweapon is not working? -
Bwandon - 22.05.2017
You haven't assigned playerb a value yet, so it's registering as playerid 0.
PHP код:
CMD:giveweapon(playerid, params[])
{
new string[128], playerb, weapon;
if(sscanf(params, "ud", playerb, weapon))
return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /giveweapon [playerid] [weapon]");
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
Let me know if it works.
Re: Any idea why /giveweapon is not working? -
rolex - 22.05.2017
Dudes, he don't have GivePlayerWeapon function in his code. He never give anything...
try it
PHP код:
CMD:giveweapon(playerid, params[])
{
new string[128], playerb, weapon;
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
if(sscanf(params, "ui", playerb, weapon)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /giveweapon [playerid] [weapon]");
{
GivePlayerWeapon(playerb, weapon, 100); // <--- (ID_OF_PLAYER, WEAPON_VALUE, AMMO_VALUE)
format(string, sizeof(string), "You've gave weapon ID: %i to ID: %i!", weapon, playerb)
SendClientMessage(playerid, 0xFFFFFFAA, string);
format(string, sizeof(string), "The player ID: %i give weapon ID %i to you!", playerid, weapon)
SendClientMessage(playerib, 0xFFFFFFAA, string);
}
return 1;
}
Re: Any idea why /giveweapon is not working? -
darkhunter332 - 23.05.2017
Thanks folks, Gonna try it once i get access to the pc.
Re: Any idea why /giveweapon is not working? -
darkhunter332 - 23.05.2017
Nevermind folks, Figured it out, Thanks!