Little help please.
#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;
		}
		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 [user] [price]");
	}
	return 1;
}
Hey, how do I restrict the price user enters. like I want maximum price to be entered by user is 100,000 not more than that.. thanks in advance
Reply
#2

That's pretty simple,

if the value "price" is the amount the user enters:

pawn Код:
if(price > 100000) return SendClientMessage(playerid, -1, "You can't enter an amount higher than 100,000);
Reply
#3

Код:
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 > 100000) return SendClientMessage(playerid, -1, "MAXIMUM amount of money is 100000.");
		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 [user] [price]");
	}
	return 1;
}
OT: i am late ;p
Reply
#4

Thank you so much +REP for you both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)