Y_Ini + zcmd + sscanf giveplayermoney help! - 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: Y_Ini + zcmd + sscanf giveplayermoney help! (
/showthread.php?tid=503978)
Y_Ini + zcmd + sscanf giveplayermoney help! -
Hyperfire - 01.04.2014
Hey guys, recently continued on my scripting and am working on a admin script. ATM I'm using enums for player data but don't know how to go about giving a player money. Now I have to remove money from PlayerInfo[playerid][Money] (the player who sends the money) and add it to the reciever's PlayerInfo[playerid][Money]. Pardon the way I write as I'm writing from a mobile phone. Thanx in advance.
Re: Y_Ini + zcmd + sscanf giveplayermoney help! -
Hyperfire - 02.04.2014
Hey guys, let me provide a bit more information.
I have a command that I want to give a given playerid money, but not by using the GivePlayerMoney(playerid, amount) code. I need the command to add money to the given player's enum I made.
In the end I need something like this.
Код:
CMD:givemoney(playerid, params[])
{
New PlayerMessage[128], TargetMessage[128], Amount;
If(sscanf(params, "ui", PlayerID, Amount))
{
SendClientMessage(playerid, COLOR_PURERED, "Usage:/givemoney [playerid\part of name][amount]");
}
Else
{
Load_Info(playerid);
If(PlayerInfo[playerid][Wallet] >= Amount))
{
\\Needed code goes here but needs to look like the following.
PlayerInfo[playerid][Money] -= Amount;
PlayerInfo[PlayerID][Money] += Amount;
\\etc, etc. Please note that PlayerID is connected to a stock and has the vallue of [MAX_PLAYERS]. I also have messages that send apon transaction but I need the money to be server side.
}
}
}
Thanx in advance.
Re: Y_Ini + zcmd + sscanf giveplayermoney help! -
RenovanZ - 02.04.2014
Like this ?
pawn Код:
stock GivePlayerMoneyEx(playerid, amount);
{
PlayerInfo[playerid][Money] += amount; // or whateva, based on your enum.
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
return 1;
}
Re: Y_Ini + zcmd + sscanf giveplayermoney help! -
Hyperfire - 03.04.2014
Worked like a charm thanx. Don't know why I didn't think of this myself lol.