GivePlayerMoney
#1

Somehow it doesn't give the player cash,
When I type /givemoney 0 500, I get a message displayed "An admin gave you $" It doesn't show the amount of money nor does it gives the player money.
Code:
PHP код:
CMD:givemoney(playeridparams[])
{
   new 
targetplayeramount;
   if(
IsPlayerAdmin(playerid))
   {
    if(
sscanf(params"ui"targetplayeramount))
    return 
SendClientMessage(playeridCOLOR_ORANGE"USAGE: /givemoney [ID] [AMOUNT]");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected!");
    new 
string[100];
    
GivePlayerMoney(targetplayeramount);
    
format(stringsizeof string"An admin gave you $%i"amount);
    
SendClientMessage(playeridCOLOR_GREENstring);
   }
    else
   {
    
SendClientMessage(playerid, -1"SERVER: Unknown command.");
   }
   return 
1;

Reply
#2

Do you have an anti-money hack system? if yes show it below.
Reply
#3

No, I just script this and that, not a server.
I want to be experienced first, so, no I don't have a anit money hack system.
Reply
#4

Simple anti cheat.
pawn Код:
ResetMoney(playerid)
{
    if(PlayerInfo[playerid][Cash] != GetPlayerMoney(playerid))
    {
        ResetPlayerMoney(playerid);
        GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
    }
    return 1;
}
And then when you purchase something:
PlayerInfo[playerid][Money] -= (+=) 500;
ResetMonet(playerid);
Reply
#5

I am not interested in an anti money cheat system, but thank you.
I just want this code to be fixed lol.
All thoughts/replies, are appreciated.
Reply
#6

So... What's wrong with the code?
Reply
#7

Stop bumping your threads that soon, you're supposed to wait 24 hours.

This is not related to the issue, but why are you doing this? Returning 0 does this by default.
Код:
    else 
   { 
    SendClientMessage(playerid, -1, "SERVER: Unknown command."); 
   }
Just do
Код:
if(!IsPlayerAdmin(playerid)) return 0;
Now, with the code. If you didn't script the base yourself it probably has an anticheat already that you do not know of. Or possibly any AC includes? As for the "An admin gave you $" problem, that all looks right.
Reply
#8

Oh god, dont be stupid please.
I JUST SCRIPTED THIS CODE, NOTHING MORE NOTHING LESS.
How can I fix my code?
Reply
#9

Try this.
PHP код:
CMD:givemoney(playeridparams[])
{
    new 
targetplayeramount;
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"SERVER: Unknown command.");
    if(
sscanf(params"dd"targetplayeramount)) return SendClientMessage(playeridCOLOR_ORANGE"USAGE: /givemoney [ID] [AMOUNT]");
    if(!
IsPlayerConnected(targetplayer)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected!");
       new 
string[100];
       
GivePlayerMoney(targetplayeramount);
       
format(stringsizeof(string), "An admin gave you $%d"amount);
       
SendClientMessage(playeridCOLOR_GREENstring);
    return 
1;

Reply
#10

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Oh god, dont be stupid please.
I JUST SCRIPTED THIS CODE, NOTHING MORE NOTHING LESS.
How can I fix my code?
The SendClientMessage is on playerid instead of the target. Also recommend using the r or u specifier instead of i or d for player targeting. That way they can type part of the players name or id instead of just id
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)