SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   backtrace (https://forum.sa-mp.com/showthread.php?t=676077)

Ertouq 29/05/2020 08:10 AM

backtrace
 
Recently on my server I discovered this:


PHP Code:

[18:31:24] [debugRun time error 4"Array index out of bounds"
[18:31:24] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[18:31:24] [debugAMX backtrace:
[
18:31:24] [debug#0 00063208 in main (playerid=0, params[]=@006e9c2c "2 0") at C:\Users\ert\OneDrive\Escritorio\sv\gamemodes\sv.pwn:3621 

and the command:


PHP Code:

CMD:sethealth(playeridparams[])
{
    new 
idFloat:healthstring[124];
    if(
sscanf(params"uf"idhealth)) return SendClientMessage(playerid, -1"/sethealth (id/name)");
    if(
PlayerInfo[playerid][Admin] < 2) return 0;
    if(
PlayerInfo[id][Logged] == 0) return SendClientMessage(playerid, -1"this player is not logged yet");
    
format(stringsizeof(string), "Admin %s has changed your health to %0.1f."GetName(playerid), health);
    
SendClientMessage(id0x1153EEFFstring);
    
SetPlayerHealth(idhealth);
    return 
1;


I've tried to change but it doesn't work. Thanks!

Runn3R 29/05/2020 08:16 AM

Re: backtrace
 
PlayerInfo is MAX_PLAYERS aka 1000 and somebody typed the wrong name hence the error cause the name doesn't exists the U parameter returned 65535..

Do a IsPlayerConnected if statement before running the PlayerInfo checks.

SharpenBlade 29/05/2020 08:18 AM

Re: backtrace
 
Quote:

Originally Posted by Ertouq (Post 4148536)
Recently on my server I discovered this:


PHP Code:

[18:31:24] [debugRun time error 4"Array index out of bounds"
[18:31:24] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[18:31:24] [debugAMX backtrace:
[
18:31:24] [debug#0 00063208 in main (playerid=0, params[]=@006e9c2c "2 0") at C:\Users\ert\OneDrive\Escritorio\sv\gamemodes\sv.pwn:3621 

and the command:


PHP Code:

CMD:sethealth(playeridparams[])
{
    new 
idFloat:healthstring[124];
    if(
sscanf(params"uf"idhealth)) return SendClientMessage(playerid, -1"/sethealth (id/name)");
    if(
PlayerInfo[playerid][Admin] < 2) return 0;
    if(
PlayerInfo[id][Logged] == 0) return SendClientMessage(playerid, -1"this player is not logged yet");
    
format(stringsizeof(string), "Admin %s has changed your health to %0.1f."GetName(playerid), health);
    
SendClientMessage(id0x1153EEFFstring);
    
SetPlayerHealth(idhealth);
    return 
1;


I've tried to change but it doesn't work. Thanks!

PHP Code:

CMD:sethealth(playeridparams[])
{
    if(
PlayerInfo[playerid][Admin] < 2) return 0;
    new 
idFloat:healthstring[124];
    if(
sscanf(params"uf"idhealth)) return SendClientMessage(playerid, -1"/sethealth (id/name) (health)");
    if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"this player is not connected yet");
    if(
PlayerInfo[id][Logged] == 0) return SendClientMessage(playerid, -1"this player is not logged yet");
    
format(stringsizeof(string), "Admin %s has changed your health to %0.1f."GetName(playerid), health);
    
SendClientMessage(id0x1153EEFFstring);
    
SetPlayerHealth(idhealth);
    return 
1;


Try this.

Runn3R 29/05/2020 08:21 AM

Re: backtrace
 
That's literally what i've said...

Why don't you let people write their own code.

Ertouq 29/05/2020 08:33 AM

Re: backtrace
 
Quote:

Originally Posted by Runn3R (Post 4148543)
That's literally what i've said...

Why don't you let people write their own code.

Don't worry, I did it myself when I read your answer as I understood. Thank you both very much.

jasperschellekens 29/05/2020 10:57 AM

Re: backtrace
 
Quote:

Originally Posted by Runn3R (Post 4148543)
That's literally what i've said...

Why don't you let people write their own code.

Yeah that's something that annoys me too. People posting large piles of shitcode without any expanation or whatsoever...
The quality of posts on sa-mp forums have reduced drastically.

What this forum need is some proper ruling and a few dedicated mods that enforce em.


All times are GMT. The time now is 04:55 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.