Any idea why /giveweapon is not working?
#1

Код:
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?
Reply
#2

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
Reply
#3

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);
Reply
#4

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?
Reply
#5

You haven't assigned playerb a value yet, so it's registering as playerid 0.

PHP код:
CMD:giveweapon(playeridparams[])
{
    new 
string[128], playerbweapon;
    if(
sscanf(params"ud"playerbweapon))
        return 
SendClientMessage(playeridCOLOR_WHITE"[Usage]: /giveweapon [playerid] [weapon]");
    if(!
IsPlayerNearPlayer(playeridplayerb2)) return SendClientMessage(playeridCOLOR_GREY"You are too far away from that player."); 
Let me know if it works.
Reply
#6

Dudes, he don't have GivePlayerWeapon function in his code. He never give anything...

try it

PHP код:
CMD:giveweapon(playeridparams[])
{
    new 
string[128], playerbweapon;
    if(!
IsPlayerNearPlayer(playeridplayerb2)) return SendClientMessage(playeridCOLOR_GREY"You are too far away from that player.");
    if(
sscanf(params"ui"playerbweapon)) return SendClientMessage(playeridCOLOR_WHITE"[Usage]: /giveweapon [playerid] [weapon]");
    {
    
GivePlayerWeapon(playerbweapon100); // <--- (ID_OF_PLAYER, WEAPON_VALUE, AMMO_VALUE)
    
format(stringsizeof(string), "You've gave weapon ID: %i to ID: %i!"weaponplayerb)
    
SendClientMessage(playerid0xFFFFFFAAstring);
    
format(stringsizeof(string), "The player ID: %i give weapon ID %i to you!"playeridweapon)
    
SendClientMessage(playerib0xFFFFFFAAstring);
    }
    return 
1;

Reply
#7

Thanks folks, Gonna try it once i get access to the pc.
Reply
#8

Nevermind folks, Figured it out, Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)