SA-MP Forums Archive
Help me please, thanks.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help me please, thanks.. (/showthread.php?tid=639845)



Help me please, thanks.. - Puff - 24.08.2017

After completing the contract, I want the killer to get the price amount he entered in /setcontract [ID] [Price]

Код:
hitmanOnPlayerDeath(playerid, killerid, reason) {
	#pragma unused reason
	new faction = GetPVarInt(killerid, "Faction");
	if(getFactionType(faction) == EFactionType_Hitman && GetPVarInt(playerid, "Contract") != 0) {
		new msg[128];
        format(msg, sizeof(msg), "* You killed %s",GetPlayerNameEx(playerid, ENameType_RPName_NoMask));
		SendClientMessage(killerid, X11_YELLOW, msg);
		format(msg, sizeof(msg), "* A hit contract was completed on you");
		SendClientMessage(playerid, X11_YELLOW, msg);
		format(msg, sizeof(msg), "%s completed the contract on %s",GetPlayerNameEx(killerid, ENameType_RPName_NoMask),GetPlayerNameEx(playerid, ENameType_RPName_NoMask));
		HitmanMessage(X11_YELLOW, msg);
		DeletePVar(playerid, "Contract");
	}
	return 1;
}
YCMD:setcontract(playerid, params[], help) {
	new user, price;
	new faction = GetPVarInt(playerid, "Faction");
    if(getFactionType(faction) != EFactionType_Hitman || GetPVarInt(playerid, "Rank") < 2) {
		SendClientMessage(playerid, X11_TOMATO_2, "You aren't a member of hitman!");
		return 1;
	}
	if(!sscanf(params, "k<playerLookup>d",user,price)) {
		if(!IsPlayerConnectEx(user)) {
			SendClientMessage(playerid, X11_TOMATO_2, "User not found");
			return 1;
		}
        if(price > 50000) return SendClientMessage(playerid, X11_TOMATO_2, "You can't enter an amount higher than $50,000.");
		SetPVarInt(user, "Contract", price);
		if(price != 0) {
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Contract Updated!");
		} else {
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Contract Removed!");
		}
	} else {
		SendClientMessage(playerid, X11_WHITE, "USAGE: /setcontract [ID] [Price ($1 - $50,000)]");
	}
	return 1;
}



Re: Help me please, thanks.. - thegamer355 - 24.08.2017

just add:
pawn Код:
GivePlayerMoney(playerid, GetPVarInt(playerid, price));
DeletePVar(playerid, price);
If i'm correct about pVar, i never really used it


Re: Help me please, thanks.. - Puff - 24.08.2017

Quote:
Originally Posted by thegamer355
Посмотреть сообщение
just add:
pawn Код:
GivePlayerMoney(playerid, GetPVarInt(playerid, price));
DeletePVar(playerid, price);
If i'm correct about pVar, i never really used it
Код:
.pwn(73) : error 017: undefined symbol "price"
Adding this under hitmanonplayerdeath and it gives me undefined symbol.. I tried adding similar GiveMoneyEx before and got same error and tried adding new price; it compiled but in game it didnt givemoney


Re: Help me please, thanks.. - thegamer355 - 24.08.2017

Right, my mistake, read the explanations about pVar and i get it now

pawn Код:
GivePlayerMoney(killerid, GetPVarInt(playerid, "Contract")); // give it to killerid, as that's the one who killed the player
This should do the trick, just make sure the giveplayermoney part is above the deletepvar part


Re: Help me please, thanks.. - Misiur - 24.08.2017

@thegamer was close, you need to get your "Contract", i.e
pawn Код:
GivePlayerMoney(playerid, GetPVarInt(playerid, "Contract"));
DeletePVar(playerid, "Contract");