12.12.2011, 21:42
Conceptz knows what he's talking about.
You need to create a global variable for stuff like this (meaning at the top of the script):
Add these new things:
You need to create a global variable for stuff like this (meaning at the top of the script):
Add these new things:
pawn Код:
// top of script
new id, amount;
// bottom of script
dcmd_bribe(playerid,params[])
{
new string[128];
if(sscanf(params, "ui", id, amount))
{
SendClientMessage(playerid,COLOR_RED,"USAGE: /bribe (Player Name/ID) (Amount)");
return 1;
}
if(playerid == id)
{
SendClientMessage(playerid,COLOR_RED,"You cannot bribe yourself!");
return 1;
}
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
return 1;
}
if(!IsPlayerConnected(id))
{
format(string,sizeof(string),"The Player ID (%d) is not connected to the server. You cannot give bribe to them.",ID);
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
if(gTeam[id] == CIVILIAN)
{
SendClientMessage(playerid,COLOR_RED,"Only Police Officers can be bribed!");
return 1;
}
if(HasBribedRecently[playerid] >= 1)
{
SendClientMessage(playerid,COLOR_RED,"Please wait before attempting to bribe someone again.");
return 1;
}
if(GetPlayerMoney(playerid) < amount)
{
SendClientMessage(playerid,COLOR_RED,"You do not have that amount of money!");
return 1;
}
if(amount > 20000 || amount < 5000)
{
SendClientMessage(playerid,COLOR_RED,"Please enter ammount from 5000$ up to 20.000$");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,id) > 15)
{
SendClientMessage(playerid,COLOR_RED,"That player is not close enough in order bribe him.");
return 1;
}
format(string,sizeof(string),"You have offered bribe to %s(%d).",PlayerName(id),id);
SendClientMessage(playerid,COLOR_SERVER,string);
format(string,sizeof(string),"You have recived $%d bribe from %s (%d). /accept or /decline.",amount,PlayerName(playerid),playerid);
SendClientMessage(id,COLOR_SERVER,string);
HasOfferforBribe[id] =1;
HasBribedRecently[playerid] =30;
return 1;
}
dcmd_accept(playerid,params[])
{
#pragma unused params
new string[128];
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
return 1;
}
if(!IsPlayerConnected(ID))
{
format(string,sizeof(string),"The Player ID (%d) is not connected to the server.",id);
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
if(HasOfferforBribe[playerid] != 1)
{
SendClientMessage(playerid,COLOR_RED,"You do not have any bribe offer to accept.");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,id) > 15)
{
SendClientMessage(playerid,COLOR_RED,"That player is not close enough in order to accept bribe.");
return 1;
}
SendClientMessage(id,COLOR_ORANGE,"Your bribe has been accepted . You are free to go!");
JailTime[id] =0;
TotalJailTime[id] =0;
Jailed[id] = false;
SetPlayerWantedLevel(id, 0);
SetPlayerInterior(id, 0);
SetPlayerPos(id, 1546.0634,-1675.3385,13.5616);
SetPlayerFacingAngle(id, 13.5616);
SetCameraBehindPlayer(id);
GivePlayerMoney(id, -amount);
format(string, sizeof(string), "%s (%d) has been released from jail.",PlayerName(id),id);
SendClientMessageToAll(COLOR_SERVER,string);
SetPlayerHealth(id, 100);
return 1;
}