The command /contract
#1

Код:
dcmd_contract(playerid, params[])
{
	new targetid;
	new reasonid;
	if(sscanf(params, "uzi", targetid, reasonid, money)) return SendClientMessage(playerid, COLOR_RED, "Usage: /contract [ID] [Reason] [Reward]");
	if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "Error: Player is not connected.");
	SendClientMessage(targetid, COLOR_RED, "Somebody has placed an contract on you!");
	GivePlayerMoney(playerid, -money);
	return 1;
}
This is my code.
What needs top happen?
If you type /contract [ID] [Reason] [Reward]
You lose the cash u typed in by REWARD.
The id gets 6 wanted stars.
The id gets the message: [NAME] has place an contract on you. Reason: [The reason here] <-- Who can do this?
And if the id gets killed by someone, he gets the reward cash.
Reply
#2

On top of your code, with your other pVars add:
pawn Код:
enum pInfo
{
    pContract
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Command (using ZCMD, might be the same way w/ dcmd, not sure, nvr used it.)

pawn Код:
COMMAND:contract(playerid, params[])
{
    new name[MAX_PLAYER_NAME], reason[100], ID, Reward;
    if(sscanf(params, "usi", ID, reason, Reward)) SendClientMessage(playerid, RED, "USAGE: /contract [ID] [Reason] [Reward]");
    else
    {
        GetPlayerName(playerid, name, sizeof(name));
        format(reason, sizeof(reason), "%s has placed a contract on you! Reason: %s", name, reason);
        GivePlayerMoney(playerid,-Reward);
        SetPlayerWantedLevel(ID, 6);
        PlayerInfo[ID][pContract]=Reward;
        SendClientMessage(ID, RED, reason);
    }
    return 1;
}
Under OnPlayerDeath add:
pawn Код:
GivePlayerMoney(killerid, PlayerInfo[playerid][pContract]);
 PlayerInfo[playerid][pContract] = 0;
Reply
#3

Here you go mate, just delete that "COMMAND:" and uncomment that "dcmd_contract", I've done this quickly so...

pawn Код:
/*dcmd_contract*/COMMAND:(playerid, params[])
{
    new targetID,reason[128], money;
    if(!sscanf(params, "us[128]i", targetID, reason, money))
    {
        if(IsPlayerConnected(targetID))
        {
            new name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], string[128];
            GetPlayerName(playerid, name, sizeof(name));
            GetPlayerName(targetID, targetname, sizeof(targetname));
            SetPlayerWantedLevel(targetID, 6);
            format(string, sizeof(string), " %s has place an contract on you. Reason: %s.",name, reason);
            SendClientMessage(targetID, 0xFFFFFFFF, string);
            format(string, sizeof(string), " You have placed a contract on %s for $%d",targetname, money);
            SendClientMessage(playerid, 0xFFFFFFFF, string);
            GivePlayerMoney(playerid, -money);
        }
        else return SendClientMessage(playerid,COLOR_RED, "Error: Player is not connected.");
    }
    else return SendClientMessage(playerid, COLOR_RED, "Usage: /contract [ID] [Reason] [Reward]");
    return 1;
}
I haven't tested it but it should work perfectly.
One more thing - You will need to make something like if some one kills that guy, he will get that reward, in this command I've made you won't get that.
Reply
#4

I added the reward portion to the code using the pVars
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)