TImer issue
#1

so i got OtherTimer() and Speedo() that are causing AMX BACKTRACE

PHP код:
[14:27:41] [debug#0 00000000 in public OtherTimer () from serverteste.amx 
[14:27:41] [debugRun time error 3"Stack/heap collision (insufficient stack size)" 
[14:27:41] [debug]  Stack pointer (STKis 0x15354B4heap pointer (HEAis 0x1535548 
[14:27:41] [debugAMX backtrace
[
14:27:41] [debug#0 00000000 in public Speedo () from serverteste.amx 
[14:27:42] [debugRun time error 3"Stack/heap collision (insufficient stack size)" 
[14:27:42] [debug]  Stack pointer (STKis 0x15354B4heap pointer (HEAis 0x1535548 
[14:27:42] [debugAMX backtrace
these are the functions

PHP код:
function OtherTimer() 

    new 
str[128], string[128]; 
    
//new username[MAX_PLAYER_NAME]; 
    
foreach(Playeri
    { 
       
/*if(IsPlayerConnected(i)) 
        { 
            GetPlayerName(i,username,sizeof(username)); 
            new Float:oldX[MAX_PLAYERS], Float:oldY[MAX_PLAYERS], Float:oldZ[MAX_PLAYERS]; 
            oldX[i] = PosX[i]; 
            oldY[i] = PosY[i]; 
            oldZ[i] = PosZ[i]; 
            GetPlayerPos(i,PosX[i],PosY[i],PosZ[i]); 
            new Float:distanta[MAX_PLAYERS]; 
            distanta[i] = GetDistanceBetweenPoints(oldX[i],oldY[i],oldZ[i],PosX[i],PosY[i],PosZ[i]); 
            if((distanta[i] > 65.0) && (PlayerData[i][Admin] == 0)) // IsLoggedIn 
            { 
                //format(string,sizeof(string), "TeleportHack: Este posibil ca %s(id:%d)sa aibe teleport hack, distanta teleportata %f(puneti-va spec).",username,i,distanta[i]); 
                   //ABroadCast(RED,string,1); 
                    
            } 
        } */ 
        
if (PlayerToPoint(2.0i2486.5198,-1645.2394,14.0772)) 
        { 
            
GameTextForPlayer(i"~w~HQ Groove St. 125"50001); 
        } 
        if (
PlayerToPoint(2.0i1172.4932,-1323.3479,15.4030)) 
        { 
            
GameTextForPlayer(i"~w~HQ Emergency Dept."50001); 
        } 
        if (
PlayerToPoint(2.0i755.3737,-1362.3281,13.5131)) 
        { 
            
GameTextForPlayer(i"~w~HQ SAN Network"50001); 
        } 
        if (
PlayerToPoint(2.0i1653.7765,-1655.5151,22.5156)) 
        { 
            
GameTextForPlayer(i"~w~HQ SA Gov"50001); 
        } 
        if (
PlayerToPoint(2.0i1899.4996,-2005.1289,13.5469)) 
        { 
            
GameTextForPlayer(i"~w~HQ Varrio Nuevo Estrada"50001); 
        } 
        if (
PlayerToPoint(2.0i2000.0482,-1114.3588,27.1250)) 
        { 
            
GameTextForPlayer(i"~w~HQ Ballas"50001); 
        } 
        if(
PlayerData[i][IsLoggedIn] == false && ByPASS[i] == 0
        { 
            if (
AFKLoggin[i] != -1
            { 
                
AFKLoggin[i] -= 1
                if(
AFKLoggin[i] == 0
                { 
                    
SendClientMessage(iCOLOR_LIGHTRED"** You haven't login in 40 seconds (Kicked) **"); 
                    
KickEx(i); 
                } 
            } 
        } 
        if(
PlayerData[i][Cash] != GetPlayerMoney(i))// 
         

            new 
hack GetPlayerMoney(i) - PlayerData[i][Cash]; 
            if(
hack!=0
            { 
                
ResetMoneyBar(i); 
                
UpdateMoneyBar(i,PlayerData[i][Cash]); 
            } 
        } 
        new 
FloatoldX[MAX_PLAYERS], FloatoldY[MAX_PLAYERS], FloatoldZ[MAX_PLAYERS]; 
        
oldX[i] = PosX[i]; 
        
oldY[i] = PosY[i]; 
        
oldZ[i] = PosZ[i]; 
        
GetPlayerPos(i,PosX[i],PosY[i],PosZ[i]); 
        new 
Float:distanta[MAX_PLAYERS]; 
        
distanta[i] = GetDistanceBetweenPoints(oldX[i],oldY[i],oldZ[i],PosX[i],PosY[i],PosZ[i]); 
        if(
distanta[i] == 0PlayerAFK[i] = 1
        else 
PlayerAFK[i] = 0
        
//new faction = PlayerData[i][Member] + PlayerData[i][Leader]; 
        
if(PlayerData[i][Muted] > 0
        { 
            if(
PlayerData[i][MutedTime] > 0PlayerData[i][MutedTime] -= 1
            if(
PlayerData[i][MutedTime] <= 0
            { 
                
PlayerData[i][MutedTime] = 0
                
PlayerData[i][Muted] = 0
                 
                
mysql_format(SQL,str,128,"UPDATE `users` SET `Muted`='0', `MutedTime`='0' WHERE `id`='%d'"PlayerData[i][ID]); 
                
mysql_tquery(SQL,str""""); 
                 
                
SendClientMessage(i0xFFFF00AA"* Your time of silence has ended."); 
                
format(string128"Mute time has ended!"); 
                
GameTextForPlayer(istring50001); 
            } 
        } 
        if(
PlayerData[i][PlayerCuffed] > 1
        { 
            
PlayerData[i][PlayerCuffed] -= 1
            if(
PlayerData[i][PlayerCuffed] == 0
            { 
                
GameTextForPlayer(i"~r~You broke the Cuffs, you are free!"25003); 
                
TogglePlayerControllable(i1); 
                
PlayerData[i][PlayerCuffed] = 0
            } 
        } 
        if(
PlayerData[i][Jailed] == 1
        { 
            if(
PlayerData[i][JailTime] > 0PlayerData[i][JailTime] -= 1
            
mysql_format(SQL,str,128,"UPDATE `users` SET `JailTime`='%d' WHERE `id`='%d'"PlayerData[i][JailTime], PlayerData[i][ID]); 
            
mysql_tquery(SQL,str""""); 
            if(
PlayerData[i][JailTime] <= 0
            { 
                
PlayerData[i][JailTime] = 0
                
PlayerData[i][Jailed] = 0
                 
                
mysql_format(SQL,str,128,"UPDATE `users` SET `Jailed`='0', `JailTime`='0' WHERE `id`='%d'"PlayerData[i][ID]); 
                
mysql_tquery(SQL,str""""); 
                 
                
SpawnPlayer(i); 
            } 
             
        } 
        if(
PlayerData[i][PlayerToFind] >= 0
        { 
            new 
id PlayerData[i][PlayerToFind]; 
            if(
PlayerData[id][InBizz] == -&& PlayerData[id][InHouse] == -&& PlayerData[id][InHQ] == -1
            { 
                new 
Float:X,Float:Y,Float:Z
                
GetPlayerPos(idX,Y,Z); 
                
SetPlayerCheckpoint(iX,Y,Z3); 
            } 
            else 
            { 
                if(
PlayerData[id][InBizz] > -1
                { 
                    new 
biz PlayerData[id][InBizz]; 
                    
SetPlayerCheckpoint(iBizzInfo[biz][bEntranceX],BizzInfo[biz][bEntranceY],BizzInfo[biz][bEntranceZ], 3); 
                } 
                else if(
PlayerData[id][InHouse] > -1
                { 
                    new 
house PlayerData[id][InHouse]; 
                    
SetPlayerCheckpoint(iHouseInfo[house][hEntrancex],HouseInfo[house][hEntrancey],HouseInfo[house][hEntrancez], 3); 
                } 
                else if(
PlayerData[id][InHQ] == 2) { SetPlayerCheckpoint(i2486.5198,-1645.2394,14.07723); } 
                else if(
PlayerData[id][InHQ] == 3) { SetPlayerCheckpoint(i2000.0482,-1114.3588,27.12503); } 
                else if(
PlayerData[id][InHQ] == 4) { SetPlayerCheckpoint(i1899.4996,-2005.1289,13.54693); } 
                else if(
PlayerData[id][InHQ] == 5) { SetPlayerCheckpoint(i1653.7765,-1655.5151,22.51563); } 
                else if(
PlayerData[id][InHQ] == 6) { SetPlayerCheckpoint(i755.3737,-1362.3281,13.51313); } 
                else if(
PlayerData[id][InHQ] == 7) { SetPlayerCheckpoint(i1172.4932,-1323.3479,15.40303); } 
            } 
        } 
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerData[i][Speedlimit]) 
        {
//Speedlimit 
            
new abc
            
GetPlayerKeys(ia,c); 
            new 
speed PlayerData[i][Speed]; 
            if(
== && speed PlayerData[i][Speedlimit]) 
            { 
                new 
newspeed speed PlayerData[i][Speedlimit]; 
                
ModifyVehicleSpeed(GetPlayerVehicleID(i), -newspeed); 
            } 
        } 
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER
        { 
            new 
speed=GetPlayerSpeed(i,0); 
            new 
string23[256],sendername[25]; 
            
GetPlayerName(i,sendername,sizeof(sendername)); 
            if(
speed>230
            { 
                
format(string23256"SpeedHack: %s(id:%d) conduce cu %.0d km/h folosind un %s(puneti-va spec)."sendername,i,speed,vehName[GetVehicleModel(GetPlayerVehicleID(i))-400]); 
                
ABroadCast(RED,string23,1); 
            } 
           } 
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER && !IsPlayerNPC(i)) 
        {
//Radar 
            
if(PlayerData[i][RadarUse] > 0
            { 
                new 
Float:x1Float:y1Float:z1
                
GetPlayerPos(i,x1,y1,z1); 
                foreach(
Playero
                { 
                    if(
!= i
                    { 
                        if(
IsPlayerInRangeOfPoint(o20x1,y1,z1)) 
                          { 
                            new 
factiono PlayerData[o][Member] + PlayerData[o][Leader]; 
                            new 
speed PlayerData[o][Speed]; 
                            if(
speed >= PlayerData[i][RadarUse] && GetPlayerState(o) == PLAYER_STATE_DRIVER
                            { 
                                if(
factiono != || PlayerData[o][OnDuty]  == 0
                                { 
                                    
format(stringsizeof(string), "%s(%d) conduce cu  %.0d km/h, Radar Limit: %d km/h!",PlayerData[o][Name],o,speed,PlayerData[i][RadarUse]); 
                                      
SendClientMessage(iCOLOR_REDDstring); 
                                      
format(stringsizeof(string), "Ai fost prins de radarul pus de  %s(%d)  cu o viteza de  %.0d km/h, Limita Legala Radar: %d km/h! ,ai fost amendat cu 50.000 $",PlayerData[i][Name],i,speed,PlayerData[i][RadarUse]); 
                                      
SendClientMessage(oCOLOR_REDDstring); 
                                     
GivePlayerCash(o, -50000); 
                                } 
                            } 
                        } 
                    } 
                } 
                if(
PlayerData[i][Speed] > 1
                { 
                    
PlayerData[i][RadarUse] = 0
                    
SendClientMessage(iCOLOR_LIGHTBLUE2"You stopped your radar."); 
                } 
            } 
        } 
        if(
GetPlayerSpecialAction(i) == SPECIAL_ACTION_USEJETPACK && PlayerData[i][Admin] < 1
        { 
            new 
reasonn[64]; 
            
format(reasonn,sizeof(reasonn),"Jetpack"); 
            
BanA(i,"AdmBot",reasonn,0,0,1); 
        } 
    } 

PHP код:
function Speedo() 

    new 
str[128]; 
     foreach(
Playeri
    { 
        if(
GetPlayerState(i) == PLAYER_STATE_DRIVER && !IsPlayerNPC(i) && Allowed[i] == 0
        { 
            new 
FloatoldX[MAX_PLAYERS], FloatoldY[MAX_PLAYERS], FloatoldZ[MAX_PLAYERS]; 
            
oldX[i] = PosX[i]; 
            
oldY[i] = PosY[i]; 
            
oldZ[i] = PosZ[i]; 
            
GetPlayerPos(i,PosX[i],PosY[i],PosZ[i]); 
            new 
Float:distanta[MAX_PLAYERS]; 
            
distanta[i] = GetDistanceBetweenPoints(oldX[i],oldY[i],oldZ[i],PosX[i],PosY[i],PosZ[i]); 
             
            new 
str1[128]; 
            new 
vehicle GetPlayerVehicleID(i); 
            new 
oldspeed PlayerData[i][Speed]; 
            
PlayerData[i][Speed] = GetVehicleSpeed(GetPlayerVehicleID(i), 0); 
            new 
newspeed PlayerData[i][Speed]; 
            new 
acceleration abs(newspeed oldspeed); 
            new 
Consume = (((acceleration 10) + 1) * (newspeed 20)); 
            new 
Float:Consume2 float(Consume); 
            new 
carid FindSpawnID(vehicle); 
            if(!(
IsAPlane(vehicle) || IsABoat(vehicle) || IsABike(vehicle))) 
            { 
                
Gas[vehicle] -= Consume2/500
                if(
Gas[vehicle] <= 0
                { 
                    new 
e,l,a,d,b,bo,o
                    
GetVehicleParamsEx(vehicle,e,l,a,d,b,bo,o); 
                    
SetVehicleParamsEx(vehicle,0,l,a,d,b,bo,o); 
                    
format(str1,sizeof(str1),"Fuel: ~r~NO FUEL"); // 
                    
PlayerTextDrawSetString(iFuellstr1); 
                    
Gas[vehicle] = 0
                } 
            } 
            else 
            { 
                
Consume 0
            } 
             
            if(
CarInfo[carid][cID] != -&& carid != 0)    PlayerTextDrawHide(iOdometerr); 
            
PlayerTextDrawHide(iSpeedd); 
            
PlayerTextDrawHide(iFuell);  
            
PlayerTextDrawHide(iDestination);  
            
PlayerTextDrawHide(iDestinationKM); 
            
//PlayerTextDrawHide(i, Radio); 
             
            
CarInfo[carid][KM] += distanta[i]/1000
            
mysql_format(SQLstr,128,"UPDATE `cars` SET `KM`='%f' WHERE `ID`='%d' LIMIT 1",CarInfo[carid][KM],carid); 
            
mysql_tquery(SQLstr""""); 
     
            if(
CarInfo[carid][cID] != -&& carid != 0
            { 
                
format(str1,sizeof(str1),"Odometer: ~y~%.2f ~w~KM",CarInfo[carid][KM]); 
                
PlayerTextDrawSetString(iOdometerrstr1); 
            } 
             
            if(
PlayerData[i][Speed] <= 110
            { 
                
format(str1,sizeof(str1),"Speed: ~y~%d ~w~KM/H",PlayerData[i][Speed]); 
                
PlayerTextDrawSetString(iSpeeddstr1); 
            } 
            if(
PlayerData[i][Speed] > 110 && PlayerData[i][Speed] <= 160
            { 
                
format(str1,sizeof(str1),"Speed: ~b~%d ~w~KM/H",PlayerData[i][Speed]); 
                
PlayerTextDrawSetString(iSpeeddstr1); 
            } 
            if(
PlayerData[i][Speed] > 160
            { 
                
format(str1,sizeof(str1),"Speed: ~r~%d ~w~KM/H",PlayerData[i][Speed]); 
                
PlayerTextDrawSetString(iSpeeddstr1); 
            } 
             
            if(
Gas[vehicle] > 0
            { 
                
format(str1,sizeof(str1),"Fuel: %d  %%"floatround(Gas[vehicle], floatround_round)); // 
                 
                //format(str1,sizeof(str1),"Fuel: %d %% (C: %d %%)", floatround(Gas[vehicle], floatround_round), Consume); // 
                
PlayerTextDrawSetString(iFuellstr1); 
            } 
             
            if(
DestinationSet[i] == 0
            { 
                
format(str1,sizeof(str1),"Destination: "); // 
                
PlayerTextDrawSetString(iDestinationstr1); 
            } 
            else 
            { 
                
/*GetPlayer3DZone2(DestSet[i][0],DestSet[i][1],DestSet[i][2],zone,30); 
                format(str1,sizeof(str1),"Destination: ~y~%s",zone); // 
                PlayerTextDrawSetString(i, Destination, str1); */ 
                 
                
new Float:distance GetPlayerDistanceFromPoint(iDestSet[i][0],DestSet[i][1],DestSet[i][2]); 
                
format(str1,sizeof(str1),"Destination:  ~y~%.2f ",distance); // 
                
PlayerTextDrawSetString(iDestinationKMstr1); 
                
PlayerTextDrawShow(iDestinationKM); 
            } 
             
        
/*    if(RadioSet[i] == 0) 
            { 
                format(str1,sizeof(str1),"Radio: ~r~OFF"); // 
                PlayerTextDrawSetString(i, Radio, str1); 
            } 
            else 
            { 
                format(str1,sizeof(str1),"Radio: ~y~%s",RadioName(RadioSet[i])); // 
                PlayerTextDrawSetString(i, Radio, str1); 
            }*/ 
             
            
if(CarInfo[carid][cID] != -&& carid != 0)    PlayerTextDrawShow(iOdometerr); 
            
PlayerTextDrawShow(iSpeedd); 
            
PlayerTextDrawShow(iFuell);  
            
PlayerTextDrawShow(iDestination);  
            
//PlayerTextDrawShow(i, Radio); 
        

        else 
        { 
            
PlayerTextDrawHide(iOdometerr); 
            
PlayerTextDrawHide(iSpeedd); 
            
PlayerTextDrawHide(iFuell);  
            
PlayerTextDrawHide(iDestination);  
        
//    PlayerTextDrawHide(i, Radio); 
            
PlayerTextDrawHide(iDestinationKM); 
        } 
    } 

Reply
#2

******: "Reduce the size of local variables. There is no reason why you should ever exceed the stack if you don't use stupid big arrays all over the place (as I've written about countless times before)."

Use the goddamn search function instead of creating topics instantly...
I found this with 1 search attempt:
https://sampforum.blast.hk/showthread.php?tid=390682

Im not sure but the following might be the problem:
new Float: oldX[MAX_PLAYERS], Float: oldY[MAX_PLAYERS], Float: oldZ[MAX_PLAYERS];

Try to create them globally instead as globals are not stacked.
Reply
#3

i used search i reduced some but still got errors..im gonna try more and i`ll reply
Reply
#4

Quote:
Originally Posted by PepsiCola23
Посмотреть сообщение
i used search i reduced some but still got errors..im gonna try more and i`ll reply
reducing them should fix it.
Reply
#5

SOLVED: transformed it into a global variable

PHP код:
new Float:OldX[MAX_PLAYERS], Float:OldY[MAX_PLAYERS], Float:OldZ[MAX_PLAYERS
at top of script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)