How to make this command charge money
#1

How can i make this command charge money if it's used...

Код:
	if (strcmp("/fix", cmd, true) == 0)
	{
 	if (gTeam[playerid] == TEAM_MECHANIC)
	{
 		new giveplayerid;
		new giveplayer[MAX_PLAYER_NAME];
		new sendername[MAX_PLAYER_NAME];
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_ORANGE,"USAGE: /fix [playerid]");
 		if(IsPlayerConnected(strval(tmp)) == 0) return SendClientMessage(playerid, COLOR_ORANGE, "[ERROR]: The ID you have entered does not exist!");

 		giveplayerid = ReturnUser(tmp);
 		SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
		GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer));
		GetPlayerName(playerid,sendername,sizeof(sendername));
		format(tmp,sizeof(tmp),"You fixed %s car!",giveplayer);
		SendClientMessage(playerid,0x33AA33AA,tmp);
		format(tmp,sizeof(tmp),"%s has fixed your engine!",sendername);
		SendClientMessage(giveplayerid,0xAA3333AA,tmp);
  }
		else return SendClientMessage(playerid, COLOR_LIME, "Only Mechanics can use that command so stfu and dont do it again!");
	return 1;
		}
So it checks if the player has the money, if not it says "Player can not afford the fix" and if he does it takes away 1000 and gives it to the mechanic who fixed his car
Reply
#2

pawn Код:
if(GetPlayerMoney(playerid) < 1000) // 1000 is the amount of cash they need
  return SendClientMessage(playerid, YOUR_COLOR, "You can not afford this."); // change YOUR_COLOR
And do:

pawn Код:
GivePlayerMoney(playerid, - 1000);
To take away $1000
Reply
#3

Quote:
Originally Posted by Sneaky'
pawn Код:
if(GetPlayerMoney(playerid) < 1000) // 1000 is the amount of cash they need
  return SendClientMessage(playerid, YOUR_COLOR, "You can not afford this."); // change YOUR_COLOR
And do:

pawn Код:
GivePlayerMoney(playerid, - 1000);
To take away $1000
Thanks a lot! it worked! Do you also know how to do this?

http://forum.sa-mp.com/index.php?topic=114592.0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)