Command help - 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: Command help (
/showthread.php?tid=583230)
Command help -
NexySamp - 26.07.2015
So what this command does it allows a player to pay money for remowing his wanted level in a police station.But the thing is the command is set to check if atleast 1 police officer is online to allow a player to pay his wanted level.I want to set it that a player can pay his wanted level even if a police officer is not online,how can i do that,what do i need to change?? Help
PHP код:
COMMAND:kazna(playerid,params[])
{
if (APlayerData[playerid][LoggedIn] == true && GetPlayerWantedLevel(playerid) > 0)
{
new Pronasao = 0;
new Policajaca = 0;
new Cijena = 0;
new Puna = 0;
for (new i = 0; i < 5; i++)
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(PolicijskeKazne[i], X, Y, Z);
if (IsPlayerInRangeOfPoint(playerid, 2.5, X, Y, Z))
{
Pronasao = 1;
}
}
if(Pronasao == 0) return 0;
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i) && APlayerData[i][PlayerClass] == ClassPolice){
Policajaca = Policajaca + 1;
}
}
Cijena = ((GetPlayerWantedLevel(playerid) * 1000) / Policajaca) / 2;
Cijena = floatround(Cijena, floatround_round);
Puna = Cijena * Policajaca;
new Linija[128], Nadimak[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nadimak, sizeof(Nadimak));
format(Linija, sizeof(Linija), "Igrac %s je platio jamcevinu za svoje prekrsaje. Dobio si %i$.", Nadimak, Cijena);
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i) && APlayerData[i][PlayerClass] == ClassPolice){
APlayerData[i][PlayerMoney] = APlayerData[i][PlayerMoney] + Cijena;
SendClientMessage(i, 0xFFFFFF, Linija);
}
}
APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] - Puna;
PostaviWantedLevel(playerid, 0);
new LinijaZ[128];
format(LinijaZ, sizeof(LinijaZ), "Uspjesno si platio svoju jamcevinu u iznosu od %i$. Pokusaj smanjiti prekrsaje sljedeci put.", Puna);
SendClientMessage(playerid, 0xFFFFFF, LinijaZ);
return 1;
}
return 0;
}
Re: Command help -
TwinkiDaBoss - 27.07.2015
if you are using GetPlayerWantedlevel
pawn Код:
GetWantedPrice(playerid) //Add this anywhere in the script
{
new wantedprice;
switch(GetPlayerWantedLevel(playerid))
{
case 0: wantedprice = 0;
case 1: wantedprice = 10;
case 2: wantedprice = 20;
case 3: wantedprice = 30;
//add more if u want to
default: wantedprice = 0;
}
return wantedprice;
}
//Add this where you are checking if the cop is offline.
//Kada nema pandura offline dodaj ovo
if(GetPlayerMoney(playerid) < GetWantedPrice(playerid)) //Proveravas da li ima para
return SendClientMessage(playerid,COLOR_RED,"Not enough money"); //Ako nema para
GivePlayerMoney(playerid,-GetWantedPrice(playerid)); //Smanjujemo pare
SetPlayerWantedLevel(playerid,0); //stavljas wanted na 0
}
Re: Command help -
TwinkiDaBoss - 27.07.2015
Or just use this
When you check if there are any cops online/offline
pawn Код:
new price = GetPlayerWantedLevel(playerid)*10; //cena svakog wanted levela ce biti 10$. Znaci 10 wanteda = 100. 10x10
if(GetPlayerMoney(playerid) < price) //proveravamo da li ima para
return SendClientMessage(playerid,COLOR_RED,"Nemas dovoljno para");
GivePlayerMoney(playerid,-price);