16.10.2010, 06:25
When i type cuff command, it multiplyes the vehicles on my server by 1. So every time i type it, i get one more of the same vehicle in the same spot.
I dont know if it has to do with "GetDistanceBetweenPlayers" because since i swithced from IsPlayerInRangeOfPoint, i get this bug
I dont know if it has to do with "GetDistanceBetweenPlayers" because since i swithced from IsPlayerInRangeOfPoint, i get this bug
pawn Код:
COMMAND:cuff(playerid, params[])
{
new id,Cuff[MAX_PLAYERS],Name[MAX_PLAYER_NAME],string[MAX_PLAYERS],pskin = GetPlayerSkin(playerid);
for (new i=0; i<MAX_PLAYERS; i++){
if(pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288){
if(sscanf(params,"u", id))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /cuff [id]");
if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found.");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xC0C0C0FF,"**You can't cuff someone from a vehicle.");
if(id == playerid)return SendClientMessage(playerid,0xC0C0C0FF,"**You cannot cuff yourself.");
if(GetDistanceBetweenPlayers(playerid,id)> 2)return SendClientMessage(playerid,0xC0C0C0FF,"You are to far from that player");
}else return SendClientMessage(playerid,0xC0C0C0FF,"You dont have permisson to access this command.");
{
TogglePlayerControllable(id,false);
}
{
GetPlayerName(playerid, Name, sizeof(Name));
format(string, sizeof(string), "You have been restrained in handcuffs by %s.",Name);
}SendClientMessage(id,0xFF0000FF,string);
}
Cuff[id] = 1;
return 0;
}
pawn Код:
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}