Need help with server-side money.
#1

Hello, so I do not have any scripting experience, just started developing a SAMP server just around three days ago. But enough with my life stories and let's get to my problem.

So here's the thing. I took XtremeAdmin2 and I got my serverside money from Norn's tutorial ( https://sampforum.blast.hk/showthread.php?tid=71136 ).
And now, when I use the /setcash command from XtremeAdmin2...

pawn Код:
dcmd_setcash(playerid,params[]) {
    if(IsPlayerCommandLevel(playerid,"setcash")) {
        new tmp[256],tmp2[256],Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(!strlen(tmp)||!strlen(tmp2)||!IsNumeric(tmp2)||!(strval(tmp2) >= 1 && strval(tmp2) <= 1000000)) return SendClientMessage(playerid,red,"Syntax Error: \"/SETCASH <NICK OR ID> <1 - 1,000,000>\".");
        new id; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp);
        if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID) {
            SendCommandMessageToAdmins(playerid,"SETCASH");
            new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
            if(id != playerid) { format(string,256,"Administrator \"%s\" has set your cash to $%d.",name,strval(tmp2)); SendClientMessage(id,yellow,string); format(string,256,"You have set \"%s's\" cash to $%d.",ActionName,strval(tmp2)); SendClientMessage(playerid,yellow,string); }
            else { format(string,256,"You have set your cash to $%d.",strval(tmp2)); SendClientMessage(playerid,yellow,string); }
            ResetPlayerMoney(id); return GivePlayerMoney(id,strval(tmp2));
        } return SendClientMessage(playerid,red,"ERROR: You can not set a disconnected player's cash.");
    } else return SendLevelErrorMessage(playerid,"setcash");
}

The server-side money anti-hack timer gets in it's way and doesn't let me /setcash on somebody.

pawn Код:
public MoneyTimer()
{
    new username[MAX_PLAYER_NAME];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerCash(i) != GetPlayerMoney(i))
            {
                ResetMoneyBar(i);//Resets the money in the original moneybar, Do not remove!
                UpdateMoneyBar(i,GetPlayerCash(i));//Sets the money in the moneybar to the serverside cash, Do not remove!
                new hack = GetPlayerMoney(i) - GetPlayerCash(i);
                GetPlayerName(i,username,sizeof(username));
                printf("%s has picked up/attempted to spawn $%d.", username,hack);
            }
        }
    }
}
So, could anybody please help me? I tried doing something with CallRemoteFunction, but then, my money just goes up to infinite and doesn't save in my account's .ini file.
Reply
#2

pawn Код:
ResetPlayerMoney(id); return GivePlayerMoney(id,strval(tmp2));
To

pawn Код:
ResetPlayerMoney(id); return GivePlayerCash(id,strval(tmp2));
Not sure what anti-money hack you are using but I assume it's meant to be that.
Reply
#3

I did what you said, but now, another error comes up

pawn Код:
C:\Documents and Settings\Administrator\My Documents\Downloads\Basic RP Script Scratch FIX\filterscripts\XtremeAdmin2.pwn(640) : error 017: undefined symbol "GivePlayerCash"

1 Error.
The thing is, my cash functions are in my gamemode and the XtremeAdministrator2 with the /setcash command is a filescript. So can you help me?

Here's all of my 'Cash' stuff.

pawn Код:
#define ResetMoneyBar ResetPlayerMoney
#define UpdateMoneyBar GivePlayerMoney

new Cash[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("MoneyTimer", 1000, 1);

public OnPlayerConnect(playerid)
{
    ResetPlayerCash(playerid); //Resetting the players cash variable to zero.

forward GivePlayerCash(playerid, money);
forward SetPlayerCash(playerid, money);
forward ResetPlayerCash(playerid);
forward GetPlayerCash(playerid);

public GivePlayerCash(playerid, money)
{
    Cash[playerid] += money;
    ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove!
    UpdateMoneyBar(playerid,Cash[playerid]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    return Cash[playerid];
}
public SetPlayerCash(playerid, money)
{
    Cash[playerid] = money;
    ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove!
    UpdateMoneyBar(playerid,Cash[playerid]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    return Cash[playerid];
}
public ResetPlayerCash(playerid)
{
    Cash[playerid] = 0;
    ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove!
    UpdateMoneyBar(playerid,Cash[playerid]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    return Cash[playerid];
}
public GetPlayerCash(playerid)
{
    return Cash[playerid];
}

public MoneyTimer()
{
    new username[MAX_PLAYER_NAME];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerCash(i) != GetPlayerMoney(i))
            {
                ResetMoneyBar(i);//Resets the money in the original moneybar, Do not remove!
                UpdateMoneyBar(i,GetPlayerCash(i));//Sets the money in the moneybar to the serverside cash, Do not remove!
                new hack = GetPlayerMoney(i) - GetPlayerCash(i);
                GetPlayerName(i,username,sizeof(username));
                printf("%s has picked up/attempted to spawn $%d.", username,hack);
            }
        }
    }
}
And here is the current /setcash command
pawn Код:
dcmd_setcash(playerid,params[]) {
    if(IsPlayerCommandLevel(playerid,"setcash")) {
        new tmp[256],tmp2[256],Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(!strlen(tmp)||!strlen(tmp2)||!IsNumeric(tmp2)||!(strval(tmp2) >= 1 && strval(tmp2) <= 1000000)) return SendClientMessage(playerid,red,"Syntax Error: \"/SETCASH <NICK OR ID> <1 - 1,000,000>\".");
        new id; if(!IsNumeric(tmp)) id = ReturnPlayerID(tmp); else id = strval(tmp);
        if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID) {
            SendCommandMessageToAdmins(playerid,"SETCASH");
            new string[256],name[24],ActionName[24]; GetPlayerName(playerid,name,24); GetPlayerName(id,ActionName,24);
            if(id != playerid) { format(string,256,"Administrator \"%s\" has set your cash to $%d.",name,strval(tmp2)); SendClientMessage(id,yellow,string); format(string,256,"You have set \"%s's\" cash to $%d.",ActionName,strval(tmp2)); SendClientMessage(playerid,yellow,string); }
            else { format(string,256,"You have set your cash to $%d.",strval(tmp2)); SendClientMessage(playerid,yellow,string); }
            ResetPlayerMoney(id); return GivePlayerCash(id,strval(tmp2));
        } return SendClientMessage(playerid,red,"ERROR: You can not set a disconnected player's cash.");
    } else return SendLevelErrorMessage(playerid,"setcash");
}
So once again, my Cash publics are in my gamemode and /setcash is in a filescript. Please help!
Reply
#4

Use
pawn Код:
CallRemoteFunction("GivePlayerCash","dd",playerid,amount);
Reply
#5

Replace

pawn Код:
ResetPlayerMoney(id); return GivePlayerCash(id,strval(tmp2));
with

pawn Код:
CallRemoteFunction("SetPlayerCash","dd",id,strval(tmp2));
return 1;
Reply
#6

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Replace

pawn Код:
ResetPlayerMoney(id); return GivePlayerCash(id,strval(tmp2));
with

pawn Код:
CallRemoteFunction("SetPlayerCash","dd",id,strval(tmp2));
return 1;
Big thanks man! You fixed my problem! And by the way, your car ownership system is the best
Reply
#7

Quote:
Originally Posted by Gytis0
Посмотреть сообщение
Big thanks man! You fixed my problem! And by the way, your car ownership system is the best
Thanks
Reply
#8

WOW OMG! MadeMan I am using your FS and I am having the EXACT same problem and I think you just solved all my problems lol! Dude your FS is the best man! AVS FTW!!!

EDIT: Didn't work for me I dunno how to write it lol doh!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)