SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/05/2020, 08:10 AM   #1
Ertouq
Huge Clucker
 
Ertouq's Avatar
 
Join Date: Jul 2014
Posts: 233
Reputation: 4
Default 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!
Ertouq is offline   Reply With Quote
Old 29/05/2020, 08:16 AM   #2
Runn3R
Huge Clucker
 
Runn3R's Avatar
 
Join Date: Dec 2013
Location: Croatia, Split
Posts: 420
Reputation: 36
Default 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.
Runn3R is offline   Reply With Quote
Old 29/05/2020, 08:18 AM   #3
SharpenBlade
Big Clucker
 
Join Date: May 2020
Posts: 175
Reputation: 23
Default Re: backtrace

Quote:
Originally Posted by Ertouq View Post
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.
SharpenBlade is offline   Reply With Quote
Old 29/05/2020, 08:21 AM   #4
Runn3R
Huge Clucker
 
Runn3R's Avatar
 
Join Date: Dec 2013
Location: Croatia, Split
Posts: 420
Reputation: 36
Default Re: backtrace

That's literally what i've said...

Why don't you let people write their own code.
Runn3R is offline   Reply With Quote
Old 29/05/2020, 08:33 AM   #5
Ertouq
Huge Clucker
 
Ertouq's Avatar
 
Join Date: Jul 2014
Posts: 233
Reputation: 4
Default Re: backtrace

Quote:
Originally Posted by Runn3R View Post
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.
Ertouq is offline   Reply With Quote
Old 29/05/2020, 10:57 AM   #6
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,065
Reputation: 106
Default Re: backtrace

Quote:
Originally Posted by Runn3R View Post
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.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
amx backtrace XSharkX Scripting Help 5 31/05/2018 04:48 PM
AMX Backtrace help ohmy Scripting Help 1 22/05/2018 06:04 AM
amx backtrace here PepsiCola23 Scripting Help 2 23/02/2018 10:00 PM
AMX backtrace Wahyu33 Scripting Help 4 23/02/2017 02:52 PM
AMX Backtrace [+Rep] RayC Scripting Help 2 04/01/2015 07:51 PM


All times are GMT. The time now is 11:59 PM.


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