31.01.2016, 12:49
Hello. So I have speed cameras in my server and if someone is speeding for example on 100 km/h, when it's allowed only 80 km/h, the player gets PlayerInfo[i][pWantedLevel]++;. There is a police class, in which you can use a command "/fine", to remove wanted levels from a player for cash, which means, police gets cash and score for giving a fine for a player.
Each WantedLevel is $500. If wanted level is 2, then $1000, if 3 = $1500 etc. I want to know, would be there a short way, like calculating the wanted levels? I just don't want to write a really long line of if(PlayerInfo[playerid][pWantedLevel] < 1), if(PlayerInfo[playerid][pWantedLevel] < 2) etc. But when 50*500=$25000
Here is the code, from "/fine" command:
Each WantedLevel is $500. If wanted level is 2, then $1000, if 3 = $1500 etc. I want to know, would be there a short way, like calculating the wanted levels? I just don't want to write a really long line of if(PlayerInfo[playerid][pWantedLevel] < 1), if(PlayerInfo[playerid][pWantedLevel] < 2) etc. But when 50*500=$25000
Here is the code, from "/fine" command:
PHP код:
CMD:fine(playerid, params[])
{
new playerid2;
new id;
if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xCCCC99AA, "USAGE: /fine [playerid]");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player is not online.");
else
{
if(PlayerInfo[playerid][pClass] == 3)
{
if(GetDistanceBetweenPlayers(playerid, playerid2) > 5)
{
if(PlayerInfo[playerid][pWantedLevel] < 0)
{
SendClientMessage(playerid, 0x00FF00AA, "Player is not wanted!");
}
if(PlayerInfo[playerid][pWantedLevel] < 1)
{
GivePlayerMoney(playerid, 500);
GivePlayerMoney(id, -500);
new tname[MAX_PLAYER_NAME];
GetPlayerName(id,tname,sizeof(tname));
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new tstring[128];
new pstring[128];
SetPlayerScore( playerid, GetPlayerScore( playerid ) + 1 );
format(tstring,sizeof(tstring),"You Have Been Fined -$1000 By Police Officer %s(%d).",pname,playerid);
format(tstring,sizeof(pstring),"You have fined %s(%d)! And His Wanted Level Was 1 You Got +1000$",tname,id);
SendClientMessage(id,COLOR_RED,tstring);
SendClientMessage(playerid,COLOR_RED,pstring);
}
}
}
}
return 1;
}