new Hitman[MAX_PLAYERS];//For checking if the player has contract or not
new HitContract[MAX_PLAYERS];//Checking is player have a bounty or not
CMD:hitman(playerid,params[])
{
new targetid,str[128],ammount,Name[MAX_PLAYER_NAME],Name2[MAX_PLAYER_NAME];//Creating variable for name
if(sscanf(params,"ui",targetid,ammount))return SendClientMessage(playerid,-1,"Usage /hitman targetid ammount");//checking if the player uses wrong parameters
if(GetPlayerMoney(playerid)<ammount)return SendClientMessage(playerid,-1,"You dont have enough money");//checking if the player doesnt have enough money
Hitman[targetid] = 1;//Checking that the targetid has a contract
GetPlayerName(playerid,Name,sizeof(Name));//self understandable
GetPlayerName(targetid,Name2,sizeof(Name2));//self understandable
format(str,sizeof(str),"%s[%d]has hitman contract %i on %s[%d]",Name,playerid,ammount,Name2,targetid);
SendClientMessageToAll(-1,str);
SetPVarInt(playerid,"hitmanmoney",ammount);//Saving the ammount of planted money into a variable which we are going later.
for(new i=0; i<MAX_PLAYERS; i++)
{
if(i==playerid)
{
HitContract[i] = 1;//Checking that player has planted a hitman
}
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new str[128],Name[MAX_PLAYER_NAME],Name2[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
GetPlayerName(killerid,Name2,sizeof(Name2));
format(str,sizeof(str),"%s[%d]has collected money for killing hitman %s[%d]",Name2,killerid,Name,playerid);
SendClientMessageToAll(-1,str);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(HitContract[i] == 1)
{
GivePlayerMoney(killerid,GetPVarInt(i,"hitmanmoney"));//Giving killer id money
GivePlayerMoney(i,GetPVarInt(i,"hitmanmoney"));
Hitman[playerid] = 0;//Setting the variable to 0, that means player doesnt have a contract exist anymore
}
}
return 1;
}
Hitman[targetid] = 1;//Checking that the targetid has a contract
// Not Checking, its setting the targetid to hitman
-------------------------------------------------
for(new i=0; i<MAX_PLAYERS; i++)
{
if(i==playerid)
{
HitContract[i] = 1;//Checking that player has planted a hitman
}
}
// Why loop?? just add HitContract[playerid] = 1;
pawn Код:
|
CMD:checktarget(playerid,params[]) { new targetid,str[128]; if(sscanf(params,"ui",targetid))return SendClientMessage(playerid,COLOR_WHITE,"Syntax:/checktarget id"); if (Hitman[targetid] == 1) { format(str,sizeof(str),"This guy has a bounty $%i",GetPVarInt(targetid,"hitmanmoney")); SendClientMessage(playerid,COLOR_WHITE,str); } else return SendClientMessage(playerid,COLOR_WHITE,"This guy doesnt have any contracts exist"); return 1; }
CMD:showcontrats(playerid, params[])
{
if(HitContract[playerid] < 1) return 1;
new name[MAX_PLAYER_NAME+1];
SendClientMessage(playerid, -1, "--------- List of the contracts -----------");
foreach(new i : Player)
{
if(Hitman[i]) GetPlayerName(i, name, sizeof(name)), SendClientMessage(playerid, -1, "- Target : %s || Amount : %i", name, GetPVarInt(i, "hitmanmoney"));
}
return 1;
}