SetPlayerCash
#1

Hey, Instead of me having to use the GivePlayerMoney fnction, Am I able to somehow make a setplayercash?
If anyone could do it
Reply
#2

pawn Код:
CMD:setplayercash(playerid, params[])
{
    new targetid, cash;
    if(sscanf(params, "ui", targetid, cash)) return SendClientMessage(playerid, -1, "Usage: /setplayercash [playerid] [cash]");
   
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected.");
   
    PlayerInfo[targetid][Cash] = cash;
    return 1;
}
Adjust variables and enums to your script.
Reply
#3

This will set player money to xxxx you entered.
Код:
SetPlayerCash
This will add the entered amount to player's current money. If you want to decrease his money then use (-)minise xxxx (-1000)
Код:
GivePlayerMoney
Reply
#4

It's actually pretty easy to make a function for it.
pawn Код:
stock SetPlayerCash(playerid, cash)
{
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, cash);
    return 1;
}

Quote:
Originally Posted by [vTc]Patroool
Посмотреть сообщение
This will set player money to xxxx you entered.
Код:
SetPlayerCash
This will add the entered amount to player's current money. If you want to decrease his money then use (-)minise xxxx (-1000)
Код:
GivePlayerMoney
Sorry mate, but SetPlayerCash isn't a native function...
Reply
#5

pawn Код:
#define SetPlayerCash(%0,%1) ResetPlayerMoney(%0), GivePlayerMoney(%0,%1)
Or
pawn Код:
SetPlayerCash(playerid, cash)
{
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, cash);
}
EDIT: Ceathor beat me.
Reply
#6

Quote:
Originally Posted by Robo_N1X
Посмотреть сообщение
pawn Код:
#define SetPlayerCash(%0,%1) ResetPlayerMoney(%0), GivePlayerMoney(%0,%1)
Or
pawn Код:
SetPlayerCash(playerid, cash)
{
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, cash);
}
EDIT: Ceathor beat me.
forum.sa-mp.com: Where developers stand in line to help you!
Reply
#7

Thanks Creathor, Repped
Reply
#8

yes i made some functions like this early :

http://pastebin.com/6j5wfVt9

Stock Functions :
GivePlayerHealth(playerid, Float:health)
GivePlayerArmour(playerid, Float:armour)
GivePlayerScore(playerid, score)
SetPlayerMoney(playerid, money)
GivePlayerWantedLevel(playerid, level)
Reply
#9

Here are some examples :

pawn Код:
public OnPlayerSpawn(playerid)
{
   SetPlayerMoney(playerid, POCKET_MONEY); // 10000
}
OR :

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   if(killerid != INVALID_PLAYER_ID && IsPlayerConnected(killerid)) {
      GivePlayerHealth(killerid, 50);
      SendClientMessage(killerid, COLOR_SUCCESS, "Great! you killed a person and earn 50 HP!");
   }
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)