05.12.2013, 06:25
Hello guys. Today im going to show you how to make a simple hitman contract system. So, simply, all you have to do is do /hitman targetid ammount. If the targetid you hitted is dead, you will lost your money, and the killer id will get your money. Ight, so lets started.
All you have to do firstly, is add this to your top of script:
Ight, its time for script
Ight, We've done in the command. Now what we want is, when our target is dead, the killer id will collect our money, and we will lost our money. We gotta use OnPlayerDeath callback function for this:
Aight we have done here
I know this tutorial is simple.
Hope you guys liked it
All you have to do firstly, is add this to your top of script:
pawn Код:
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
pawn Код:
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;
}
pawn Код:
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;
}
I know this tutorial is simple.
Hope you guys liked it