13.09.2014, 14:57
So, I'm working on a spray thingy and I'm checking if a player is near a vehicle, though it doesn't work.
Like, this detects when I'm near a vehicle but spams the chat with with client message and dialogs.
And this one doesn't spam the chat and doesn't detect when I'm near vehicle:
So, I wonder, how am I supposed to fix it and make it work properly.
Like, this detects when I'm near a vehicle but spams the chat with with client message and dialogs.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE && GetPlayerWeapon(playerid) == 41)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
new Float:x, Float:y, Float:z;
GetVehiclePos(i, x, y, z);
if(IsPlayerConnected(playerid) && IsPlayerInRangeOfPoint(playerid, 10, x, y, z))
{
ShowPlayerDialog(playerid, DIALOG_CAR_SPRAY, DIALOG_STYLE_LIST, "Spray Colour", "Color White\nColor Black\nColor Red\nColor Green\nColor Blue\nColor Yellow\nColor Orange\n", "Spray", "Exit");
}
else if(!IsPlayerInRangeOfPoint(playerid, 10, x, y, z))
{
SendClientMessage(playerid, 0xFF0000FF, "You are not near any vehicle.");
}
}
}
return 1;
}
And this one doesn't spam the chat and doesn't detect when I'm near vehicle:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE && GetPlayerWeapon(playerid) == 41)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
new Float:x, Float:y, Float:z;
GetVehiclePos(i, x, y, z);
if(IsPlayerConnected(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 10, x, y, z))
{
ShowPlayerDialog(playerid, DIALOG_CAR_SPRAY, DIALOG_STYLE_LIST, "Spray Colour", "Color White\nColor Black\nColor Red\nColor Green\nColor Blue\nColor Yellow\nColor Orange\n", "Spray", "Exit");
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "You are not near any vehicle.");
}
}
}
}
return 1;
}
So, I wonder, how am I supposed to fix it and make it work properly.