14.05.2017, 00:38
Hi there for some reason when i try and use /giveweapon it says that i'm too far away from that player even tho hes infront of me.
Thats the cmd there
Код:
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; } 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); } else if(!strcmp(params, "katana", true, 6)) { if(GetPlayerWeapon(playerid) != 8) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 8); GiveDodWeapon(playerb, 8, 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); } else if(!strcmp(params, "sdpistol", true, 7)) { if(GetPlayerWeapon(playerid) != 23) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 23); GiveDodWeapon(playerb, 23, 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); } else if(!strcmp(params, "shotgun", true, 7)) { if(GetPlayerWeapon(playerid) != 25) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 25); GiveDodWeapon(playerb, 25, 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); } else if(!strcmp(params, "rifle", true, 5)) { if(GetPlayerWeapon(playerid) != 33) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 33); GiveDodWeapon(playerb, 33, 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); } else if(!strcmp(params, "mp5", true, 3)) { if(GetPlayerWeapon(playerid) != 29) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 29); GiveDodWeapon(playerb, 29, 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); } else if(!strcmp(params, "deagle", true, 6)) { if(GetPlayerWeapon(playerid) != 24) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 24); GiveDodWeapon(playerb, 24, 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); } else if(!strcmp(params, "ak47", true, 4)) { if(GetPlayerWeapon(playerid) != 30) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 30); GiveDodWeapon(playerb, 30, 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); } else if(!strcmp(params, "M4", true, 2)) { if(GetPlayerWeapon(playerid) != 31) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 31); GiveDodWeapon(playerb, 31, 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); } else if(!strcmp(params, "spas12", true, 6)) { if(GetPlayerWeapon(playerid) != 27) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 27); GiveDodWeapon(playerb, 27, 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); } else if(!strcmp(params, "sniper", true, 6)) { if(GetPlayerWeapon(playerid) != 34) return SendClientMessage(playerid, COLOR_GREY, "You are not holding the right weapon."); RemovePlayerWeapon(playerid, 34); GiveDodWeapon(playerb, 34, 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); } if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified."); if(IsPlayerCuffed(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You can't do this right now."); return 1; }