Giving money problem...
#1

So this the cmd to give a player money, any cmd that involves giving money has thing problem, though not all cmds.
PHP код:
CMD:givemoney(playeridparams[])
{
    if (!
AdminCheck(playerid4)) return 0;
    new 
idmoneymsg[128];
    if (
sscanf(params"ii"idmoney)) return SendClientMessage(playeridERRORCOLOR"Usage: /givemoney [playerid] [amount]");
    if (!
IsPlayerConnected(id)) return SendClientMessage(playeridERRORCOLOR"Invalid playerid.");
    if (
money || money 100000000) return SendClientMessage(playeridERRORCOLOR"Invalid amount. Amount must be between 1 and 100000000.");
    
GivePlayerMoney(idmoney);
    
format(msgsizeof(msg), "You have recieved $%d from an admin."money);
    
SendClientMessage(id0xBB7DE7FFmsg);
    
format(msgsizeof(msg), "Admin %s(ID:%d) has given $%d to %s(ID:%d)."Name[playerid], playeridmoneyName[id], id);
    
SendMessageToAdmins(1msg);
    
strins(msg"10"0);
    
IRC_SendMessageToAdmins(2msg);
    return 
1;

in console:

PHP код:

[debugRun time error 3"Stack/heap collision (insufficient stack size)"
[debug]  Stack pointer (STKis 0xFE0AD8heap pointer (HEAis 0xFE0AA4
[debugAMX backtrace:
[
debug#0 00051974 in ?? () from ffs.amx
[debug#1 00051a3c in ?? () from ffs.amx
[debug#2 00051a3c in ?? () from ffs.amx
[debug#3 00051a3c in ?? () from ffs.amx
[debug#4 00051a3c in ?? () from ffs.amx
[debug#5 00051a3c in ?? () from ffs.amx
..........................................................
[
debug#1237 00093988 in ?? () from ffs.amx
[debug#1238 0003b224 in public cmd_setmoney () from ffs.amx
[debug#1239 native CallLocalFunction () [004743b0] from samp-server.exe
[debug#1240 00008164 in public OnPlayerCommandText () from ffs.amx 
Seems like a problem with zcmd's shit, but then again all other cmds work
Reply
#2

Is GivePlayerMoney hooked?
Reply
#3

Was, in YSI. i removed it.
Reply
#4

Stacktrace is in reverse order. Has nothing to do with this.
Reply
#5

So what could be the fix?
Reply
#6

A function that declares local string(s) keeps calling itself so you run out of memory eventually.

I can reproduce it with 100 calls but 1237 is way too much. Anyway, compiling with debug info will give you the name of the function that causes this issue.
Reply
#7

Spams this
PHP код:
[debug#4 000656bc in public ac_GivePlayerMoney (playerid=1, money=50000) at C:\Users\iLearner\Desktop\ffss\gamemodes\ffs.pwn:37 
PHP код:
public ac_GivePlayerMoney(playeridmoney)
{
    
ac_vars[playerid][ac_lastmoneychange] = GetTickCount();
    
ac_vars[playerid][ac_money] += money;
    (
LINE 73)return GivePlayerMoney(playeridmoney);

Reply
#8

This is not the same because it'd have printed its name as it is a public function and it doesn't contain local string(s).

I don't really get why you use public function for it though, just:
pawn Код:
// at the top
ac_GivePlayerMoney(playerid, money)
{
    ac_vars[playerid][ac_lastmoneychange] = GetTickCount();
    ac_vars[playerid][ac_money] += money;
    return GivePlayerMoney(playerid, money);
}

#if defined _ALS_GivePlayerMoney
    #undef GivePlayerMoney
#else
    #define _ALS_GivePlayerMoney
#endif

#define GivePlayerMoney ac_GivePlayerMoney
Reply
#9

Not my script, helping a friend out.

Script is shitty and unoptimized, besides they still live in 0.3x world.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)