SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 03/12/2019, 06:32 PM   #1
JuzDoiTCnr
Little Clucker
 
Join Date: Nov 2014
Posts: 12
Reputation: 0
Default help please

PHP Code:
[20:20:13] [debugRun time error 4"Array index out of bounds"
[20:20:13] [debug]  Attempted to read/write array element at index 11 in array of size 11
[20:20:13] [debugAMX backtrace:
[
20:20:13] [debug#0 000a0e68 in public ServerMinutes () in 1vs1.amx 
[/PHP]
PHP Code:
[20:21:57] [debugRun time error 5"Invalid memory access"
[20:21:57] [debugAMX backtrace:
[
20:21:57] [debug#0 000a25e0 in ?? (63785596) in 1vs1.amx
[20:21:57] [debug#1 0006e978 in public OnPlayerText (0, 63785596) in 1vs1.amx 
PHP Code:
forward ServerMinutes(playerid);
public 
ServerMinutes(playerid)
{
    
ServerMinute++;

    new 
string[48],timestr[128];
    if(
ServerMinute 10)
    {
    
format(stringsizeof(string), "%d:0%d"ServerTimeServerMinute);
    }
    else
    {
    
format(stringsizeof(string), "%d:%d"ServerTimeServerMinute);
    }
    
TextDrawSetString(ServerTimeTXT,string);
    
SetPlayerTime(playerid ,ServerTimeServerMinute);
    
format(timestr,sizeof(timestr),"%s %d:00",GetDayName(),ServerTime);
    
SetWorldTime(ServerTime);

    if(
ServerMinute == 59)//if servetime variable is at 23 it puts it the variable to 0
    
{
        
ServerMinute 00;
        
ServerTime++;
        
format(timestr,sizeof(timestr),"%s %d:00",GetDayName(),ServerTime);
        
SetWorldTime(ServerTime);
    }
    if(
ServerTime == 24)//if servetime variable is at 23 it puts it the variable to 0
    
{
        
ServerTime 0;
        new 
str2[100];
        if(
gday == 6)
        {
            
gday =0;
            
format(str2sizeof(str2), "%s"GetDayName());
            
format(timestr,sizeof(timestr),"%s %d:00",GetDayName(),ServerTime);
            
SetWorldTime(ServerTime);
        }
        else
        {
            
gday++;
            
format(str2sizeof(str2), "%s"GetDayName());
            
format(timestr,sizeof(timestr),"%s %d:00",GetDayName(),ServerTime);
            
SetWorldTime(ServerTime);
        }
        
TextDrawSetString(GameDay0,str2);
        
TextDrawHideForAll(GameDay0);
        
TextDrawShowForAll(GameDay0);
    }
    
    if(
ServerTime == && ServerMinute == 0)
    {
    
MoneyBag();
    }
    if(
ServerTime && ServerTime 23 && ServerMinute == 0)
    {
        switch (
ServerTime)
        {
        case 
11,14,17,20:MoneyBag();
        }

    }
    if (
ServerMinute == 0)
    {
    if (
TextDrawCurrentAdMsg MAX_AD_MSG)
    {
    
TextDrawCurrentAdMsg ++;
    
SendClientOnScreenTextToAll(TextDrawAdMsg[TextDrawCurrentAdMsg]);
    }else{
    
TextDrawCurrentAdMsg 0;
    
SendClientOnScreenTextToAll(TextDrawAdMsg[TextDrawCurrentAdMsg]);
    }
    }
    
    return 
1;

PHP Code:
public OnPlayerText(playeridtext[])
{

    new
    
idx strfind(text"$");

    if(
idx != -1)
    {
    new
    
string[512];
    new 
pRank[256];
    
strcat(stringtext);
    do
    {
        if(
strcmp(string[idx], "$ply"true4) == 0)
        {
            new 
closeststr[100], closestplayer GetClosestPlayer(playerid);

            if(
IsPlayerConnected(closestplayer))
            
format(closeststrsizeof(closeststr), "%s (%d)",PlayerName(closestplayer),closestplayer);
            else
            
format(closeststrsizeof(closeststr), "%s (%d)",PlayerName(playerid),playerid);

            
strdel(stringidxidx 4);
            
strins(stringcloseststridx);
            continue;
        }
        else

    if (
strfind(text"$loc") != -1)
    {
        
format(string,sizeof(string),"*%s (%d): Location: {208FFF}%s",PlayerName(playerid),playerid,pInfo[playerid][pLocation]);
        
SendClientMessageToAll(GetPlayerColor(playerid),string);
        return 
0;
    }
    

        if(
GetPlayerKills(playerid) < 100)  pRank "Noob";
        else
        if(
GetPlayerKills(playerid) < 250 && GetPlayerKills(playerid) >  99)  pRank "Survivor";
        else
        if(
GetPlayerKills(playerid) < 600 && GetPlayerKills(playerid) >  249pRank "Dominator";
        else
        if(
GetPlayerKills(playerid) < 1500 && GetPlayerKills(playerid) >  599pRank "Rampager";
        else
        if(
GetPlayerKills(playerid) < 3000 && GetPlayerKills(playerid) > 1499pRank "Unstoppable";
        else
        if(
GetPlayerKills(playerid) < 5000 && GetPlayerKills(playerid) > 2999pRank "Kill Machine";
        else
        if(
GetPlayerKills(playerid) > 4999)  pRank "Godlike";

        if (
strfind(text"$rank") != -1)
        {
            
format(string,sizeof(string),"*%s (%d): Rank: {208FFF}%s",PlayerName(playerid),playerid,pRank);
            
SendClientMessageToAll(GetPlayerColor(playerid),string);
            return 
0;
        }
        if (
strfind(text"$cash") != -1)
        {
            
format(string,sizeof(string),"*%s (%d): Cash: {208FFF}%d",PlayerName(playerid),playerid,pInfo[playerid][AccMoney]);
            
SendClientMessageToAll(GetPlayerColor(playerid),string);
            return 
0;
        }
        if (
strfind(text"$bank") != -1)
        {
            
format(string,sizeof(string),"*%s (%d): Bank: {208FFF}%d",PlayerName(playerid),playerid,pInfo[playerid][AccBank]);
            
SendClientMessageToAll(GetPlayerColor(playerid),string);
            return 
0;
        }
        if (
strfind(text"$kills") != -1)
        {
            
format(string,sizeof(string),"*%s (%d): Kills: {208FFF}%d",PlayerName(playerid),playerid,pInfo[playerid][AccKills]);
            
SendClientMessageToAll(GetPlayerColor(playerid),string);
            return 
0;
        }
        if (
strfind(text"$deaths") != -1)
        {
            
format(string,sizeof(string),"*%s (%d): Deaths: {208FFF}%d",PlayerName(playerid),playerid,pInfo[playerid][AccDeaths]);
            
SendClientMessageToAll(GetPlayerColor(playerid),string);
            return 
0;
           }
        if (
strfind(text"$score") != -1)
        {
            
format(string,sizeof(string),"*%s (%d): Score: {208FFF}%d",PlayerName(playerid),playerid,pInfo[playerid][AccScore]);
            
SendClientMessageToAll(GetPlayerColor(playerid),string);
            return 
0;
           }
    
    }
    while((
idx strfind(string"$"falseidx 1)) != -1);

    
SendPlayerMessageToAll(playeridstring);
    return 
0;
    }



    if (
pInfo[playerid][AccTDMenu] > 0)
    {
        
OnPlayerEnterTextDrawMenuOption(playeridtext);
        return 
0;
    }
    if(
muted[playerid] == 1)
    {
        
SendClientMessage(playerid,L4D_RED,"You Are Muted. You Cannot Speak.");
        return 
0;
    }

    if(
stringContainsIP(text))
    {
        new 
szMsg[128];
        
advertisekick[playerid]++;
        
format(szMsgsizeof(szMsg), "%s: {FFFFFF}"MSG_SERVERIP""PlayerName(playerid));
        
SendClientMessageToAll(GetPlayerColor(playerid), szMsg);
        if(
advertisekick[playerid] == 3)
        {
            
format(szMsg,sizeof(szMsg),"***KICK: %s (%d) (ADVERTISEMENT KICK) Repetitive Advertisements",PlayerName(playerid),playerid);
            
SendClientMessageToAll(L4D_HOTPINK,szMsg);
            
SetTimerEx("kick"500false"i"playerid);
        }
        return 
0;
    }
    return 
1;

JuzDoiTCnr is offline   Reply With Quote
Old 03/12/2019, 06:42 PM   #2
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: help please

pawn Code:
if (TextDrawCurrentAdMsg < MAX_AD_MSG)
{
    TextDrawCurrentAdMsg++;
    SendClientOnScreenTextToAll(TextDrawAdMsg[TextDrawCurrentAdMsg]);
}
else
{
    TextDrawCurrentAdMsg = 0;
    SendClientOnScreenTextToAll(TextDrawAdMsg[TextDrawCurrentAdMsg]);
}
If MAX_AD_MSG is defined as 11 and `TextDrawCurrentAdMsg` is 10, the if statement is true because 10 < 11 but then you increase by one and it tries to access element at index 11. Change to:
pawn Code:
if (TextDrawCurrentAdMsg < MAX_AD_MSG - 1)

About the run time error 5, the problem is in `stringContainsIP` function. Compile with -d3 flag (for pawno editor, follow this: https://github.com/Zeex/samp-plugin-...ith-debug-info) for more information.
Calisthenics is offline   Reply With Quote
Old 04/12/2019, 05:31 PM   #3
JuzDoiTCnr
Little Clucker
 
Join Date: Nov 2014
Posts: 12
Reputation: 0
Default Re: help please

Thank you!
JuzDoiTCnr 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



All times are GMT. The time now is 12:38 PM.


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