SA-MP Forums Archive
How to make this command charge money - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to make this command charge money (/showthread.php?tid=89738)



How to make this command charge money - killdahobo99 - 04.08.2009

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


Re: How to make this command charge money - -Sneaky- - 04.08.2009

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


Re: How to make this command charge money - killdahobo99 - 04.08.2009

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