Why this function doesnt work - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why this function doesnt work (
/showthread.php?tid=325996)
Why this function doesnt work -
thimo - 15.03.2012
I got this function and at the keystatechange there is a print to see if it actually works. It does. But in this function its also and it doesnt respond Worked... :\ this is the code:
pawn Код:
// This function gets called when a police player presses the FIRE key (to fine nearby wanted players) when he's on foot
Police_FineNearbyPlayers(playerid)
{
// Setup local variables
new Float:x, Float:y, Float:z;
// Scan through all players
for (new PlayerToCheck; PlayerToCheck < MAX_PLAYERS; PlayerToCheck++)
{
// check if this player is connected
if (IsPlayerConnected(PlayerToCheck))
{
// Check if the other player isn't the same police player
if (PlayerToCheck == playerid)
{
// Check if the current player is wanted and the wanted player is driving slowly (below 30 kph)
if ((GetPlayerWantedLevel(PlayerToCheck) > 0) && (APlayerData[PlayerToCheck][PlayerSpeed] < 30))
{
// Get the position of this player
GetPlayerPos(PlayerToCheck, x, y, z);
// Check if the police-player is in range of the player (police player and wanted player must be within 10 meters of eachother)
if (IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
{
// Fine the player
Police_PayFine(playerid, PlayerToCheck);
SendClientMessage(playerid, COLOR_GREY, "Worked..");
// Exit the function
return 1;
}
// Check if the police-player is in range of the player (he can be inside his vehicle or on foot)
if (IsPlayerInRangeOfPoint(playerid, 50.0, x, y, z))
{
GameTextForPlayer(PlayerToCheck, "~r~This is the police! Stop at once!~w~", 3000, 4); // Warn the player
// Also start a timer which gives the player a chance to stop and get a fine
// If he doesn't stop, the player will be sent to jail when he gets fined
if (APlayerData[PlayerToCheck][PoliceWarnedMe] == false)
{
APlayerData[PlayerToCheck][PoliceWarnedMe] = true;
APlayerData[PlayerToCheck][Value_PoliceCanJailMe] = DefaultWarnTimeBeforeJail;
APlayerData[PlayerToCheck][Timer_PoliceCanJailMe] = SetTimerEx("Timer_PoliceCanJailPlayer", 5000, true, "i", PlayerToCheck);
}
}
}
}
}
}
return 1;
}
Thanks if you can see the problem
Re: Why this function doesnt work -
Krx17 - 15.03.2012
First problem:
pawn Код:
if (PlayerToCheck == playerid)
//should be
if (PlayerToCheck != playerid)
Re: Why this function doesnt work -
thimo - 15.03.2012
I know but i was alone on server so i wanted to try it on myself
Re: Why this function doesnt work -
thimo - 16.03.2012
Bump please people help me
Re: Why this function doesnt work -
Alternative112 - 16.03.2012
I'm not sure if the below code would actually work, but I have never made an if like this in my entire life.
Код:
if ((GetPlayerWantedLevel(PlayerToCheck) > 0) && (APlayerData[PlayerToCheck][PlayerSpeed] < 30))
should be
Код:
if (GetPlayerWantedLevel(PlayerToCheck) > 0 && APlayerData[PlayerToCheck][PlayerSpeed] < 30)