30.10.2013, 16:06
Somebody tell me why this not working, it sends a message to the cop that there is no player in range of point even there is a player in range of point.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new targetid, string[128];
new Random = random(sizeof(RandomJail));
new Float:x,Float:y,Float:z;
if ((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
{
if(LawEnforcementMode[playerid] == 1)
{
GetPlayerPos(targetid,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid, 4.5, x,y,z)) return SendClientMessage(playerid, COLOR_WHITE, "Error: There is no player in range of point.");
if(IsPlayerInRangeOfPoint(playerid, 4.5, x,y,z))
{
if(1<=GetPlayerWantedLevel(targetid)<=3)
{
if(PlayerInfo[targetid][pTicket] == 0)
{
PlayerInfo[targetid][pTicket] = 1;
PlayerInfo[targetid][pTReceived] ++;
PlayerInfo[playerid][pTIssued] ++;
SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
format(string, sizeof(string), "%s(%d) has issued you a ticket for $4000, you have 20 seconds to /pay the ticket.", GetName(playerid), playerid);
SendClientMessage(targetid, COLOR_WHITE,string);
GameTextForPlayer(targetid,"~w~Ticket is Issued~n~Type /pay to pay it",5000,4);
WantedInc[targetid] = SetTimerEx("WantedIncreaser", 20000, false, "i", targetid);
format(string, sizeof(string), "You have issued a Ticket to %s(%d) for $4000", GetName(targetid),targetid);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
if(GetPlayerWantedLevel(targetid)>=4)
{
GameTextForPlayer(targetid,"~r~Busted!",7000,4);
SetPlayerWantedLevel(targetid,0);
ResetPlayerWeapons(targetid);
PlayerInfo[targetid][pJailed] = 1;
SetPlayerInterior(targetid,3);
SetPlayerPos(targetid, RandomJail[Random][0], RandomJail[Random][1], RandomJail[Random][2]);
SetPlayerFacingAngle(targetid, RandomJail[Random][3]);
SetCameraBehindPlayer(targetid);
SetPlayerVirtualWorld(targetid,1);
SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
SetPlayerScore(targetid,GetPlayerScore(targetid)-1);
format(string, sizeof(string), "%s(%d) has been Arrested by Law Enforcement %s(%d)", GetName(targetid), targetid, GetName(playerid), playerid);
SendClientMessageToAll(COLOR_WHITE,string);
Releaser[targetid] = SetTimerEx("JailTime",60000, false, "i", targetid);
}
if(GetPlayerWantedLevel(targetid) == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "Error: There is no player in range of point");
}
}
}
}
return 1;
}