SA-MP Forums Archive
Looping causes problems - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Looping causes problems (/showthread.php?tid=570311)



Looping causes problems - JaKe Elite - 08.04.2015

UPDATES: The toy system is fixed by ignoring the slot 0 in the entire code, but not on looping (to prevent passing the problem on slot 1 and so on), I STILL NEED YOUR HELP ON VEHICLE SYSTEM.

The loop for the Toy System and Vehicle System is bugging out the stuffs of players.

#1 - The toy system slot 0, ptModelID is always 0 while the other slots toy for ptModelID is not null.
Note: 100% sure that i have a model on that slot, it saves fine. It got resets on relog (Loop)

#2 - The vehicle system slot 2 upto MAX_PLAYERVEHICLES pvPosX is always 0, while the first slot has no problems on posX.
Note: Again, this is tested. The vehicles always spawn in Flint County (Y and Z is not null only X).

Another Note:

"Remove this loop, Done, you are stupid JaKe" - No, removing the loop will cause troubles, conflicting vehicles/toys to other players, cloning. And also commenting or removing the ptModelID, pvPosX will not work. It will only work on your first connect, and on the another relog if you do not have the ID you had when you first connected. It will bug out again due to conflicting/cloning.

Code:

PHP код:
    for(new v7v++)
    {
        
PlayerVehicleInfo[playerid][v][pvModelId] = 0;
        
PlayerVehicleInfo[playerid][v][pvPosX] = 0.0;
        
PlayerVehicleInfo[playerid][v][pvPosY] = 0.0;
        
PlayerVehicleInfo[playerid][v][pvPosZ] = 0.0;
        
PlayerVehicleInfo[playerid][v][pvPosAngle] = 0.0;
        
PlayerVehicleInfo[playerid][v][pvLock] = 0;
        
PlayerVehicleInfo[playerid][v][pvLocked] = 0;
        
PlayerVehicleInfo[playerid][v][pvBLocked] = 0;
        
PlayerVehicleInfo[playerid][v][pvBLock] = 0;
        
PlayerVehicleInfo[playerid][v][pvPaintJob] = -1;
        
PlayerVehicleInfo[playerid][v][pvColor1] = 0;
        
PlayerVehicleInfo[playerid][v][pvImpounded] = 0;
        
PlayerVehicleInfo[playerid][v][pvColor2] = 0;
        
PlayerVehicleInfo[playerid][v][pvPrice] = 0;
        
PlayerVehicleInfo[playerid][v][pvTicket] = 0;
        
PlayerVehicleInfo[playerid][v][pvWeapons][0] = 0;
        
PlayerVehicleInfo[playerid][v][pvWeapons][1] = 0;
        
PlayerVehicleInfo[playerid][v][pvWeapons][2] = 0;
        
PlayerVehicleInfo[playerid][v][pvWepAmmo][0] = 0;
        
PlayerVehicleInfo[playerid][v][pvWepAmmo][1] = 0;
        
PlayerVehicleInfo[playerid][v][pvWepAmmo][2] = 0;
        
PlayerVehicleInfo[playerid][v][pvWepUpgrade] = 0;
        
// RL - 03/30/15
        
PlayerVehicleInfo[playerid][v][pvPot] = 0;
        
PlayerVehicleInfo[playerid][v][pvCrack] = 0;
        
PlayerVehicleInfo[playerid][v][pvMats] = 0;
        
PlayerVehicleInfo[playerid][v][pvHeroin] = 0;
        
PlayerVehicleInfo[playerid][v][pvMeth] = 0;
        
PlayerVehicleInfo[playerid][v][pvAcid] = 0;
        
PlayerVehicleInfo[playerid][v][pvPlate] = 0;
        
//
        
PlayerVehicleInfo[playerid][v][pvFuel] = 100.0;
        
        
//format(PlayerVehicleInfo[playerid][v][pvNumberPlate], 32, "TDSY%d", v); // Ignore this
        
strcpy(PlayerVehicleInfo[playerid][v][pvAllowPlayer], "No-ne"MAX_PLAYER_NAME);
        
PlayerVehicleInfo[playerid][v][pvAllowedPlayerId] = INVALID_PLAYER_ID;
        
        
PlayerVehicleInfo[playerid][v][pvPark] = 0;
        
ListItemReleaseId[playerid][v] = -1;
        
ListItemTrackId[playerid][v] = -1;
        
        for(new 
0MAX_MODSm++)
        {
            
PlayerVehicleInfo[playerid][v][pvMods][m] = 0;
        }
    }
    for(new 
x10x++)
    {
        
PlayerToyInfo[playerid][x][ptModelID] = 0;
        
PlayerToyInfo[playerid][x][ptBone] = 0;
        
PlayerToyInfo[playerid][x][ptPosX] = 0.0;
        
PlayerToyInfo[playerid][x][ptPosY] = 0.0;
        
PlayerToyInfo[playerid][x][ptPosZ] = 0.0;
        
PlayerToyInfo[playerid][x][ptRotX] = 0.0;
        
PlayerToyInfo[playerid][x][ptRotY] = 0.0;
        
PlayerToyInfo[playerid][x][ptRotZ] = 0.0;
        
PlayerToyInfo[playerid][x][ptScaleX] = 1.0;
        
PlayerToyInfo[playerid][x][ptScaleY] = 1.0;
        
PlayerToyInfo[playerid][x][ptScaleZ] = 1.0;
    } 



Re: Looping causes problems - JaKe Elite - 09.04.2015

BUMP


Re: Looping causes problems - Matess - 09.04.2015

The loop looks fine but you are using it maybe in wrong place? I got something similar under OnPlayerConnect before loading any stats, specially before registration.


Re: Looping causes problems - JaKe Elite - 09.04.2015

I have added some updates and boom it messed up. But idk why it got fucked i am pretty sure i didnt do anything wrong


Re : Looping causes problems - Etolas - 09.04.2015

Please show us the "enum code" where you create that: PlayerVehicleInfo

I think I've found your problem, but I'm not sure at all.


Re: Looping causes problems - JaKe Elite - 09.04.2015

well i cant i am on mobile but it has the array setup PlayetVehicleInfo[MAX_PLAYERS+1][pvInfo] plus one because 501 will be used for offline id purposes


Re : Looping causes problems - Etolas - 09.04.2015

Ok great, and could you give me an example of information, for exemple: pvMats

You define it pvMats[X] ?


Re: Looping causes problems - JaKe Elite - 09.04.2015

Uep ..


Re : Looping causes problems - Etolas - 09.04.2015

It's the problem I think, when u use enum, you can't do that I think

pInfo[X], because de X will be considered as a string. I'm not sure but I think it's the problem


Re: Looping causes problems - Matess - 09.04.2015

I hope that you have something like this
PHP код:
PlayetVehicleInfo[MAX_PLAYERS+1][7][pvInfo
not only

PHP код:
PlayetVehicleInfo[MAX_PLAYERS+1][pvInfo