Sign in to follow this  
Followers 0

Stored arrays...

1 post in this topic

Hey fellow scripters!

So Random problem im having... 

I have an array thats stored serverside that basically stores a players UID and a couple of other variables when a player executes a specific command.

Now everything is stored correctly and if I diag_log it its all listed correctly in the output. For example say i have 2 players have spawned a vehicle:

PersonalVehicle_cache = [[player1sUID, "vehicle 1 ID", 1, "Exile_Bike_MountainBike", 1],[player2sUID, "vehicle 2 ID", 1, "Exile_Bike_MountainBike", 0] ];

Im checking the array to see whether _playerID is found anywhere in the array and if yes then it outputs all the relevant info for the script. (namely preventing them from spawning another vehicle)

_veh = objNull;
_ind = ((count PersonalVehicle_cache) - 1);

//Check array to see if player has spawned a vehicle before
    if (_playerID in _x) then {
        _veh = _x select 1;
        _spawnallowed = _x select 2;
        _storedvehClassName = _x select 3;
        _respectvehicleused = _x select 4;
        _ind = _forEachIndex;
} forEach PersonalVehicle_cache;     

The problem is, with only a couple of players on a server it runs fine.

BUT As soon as theres more than just a couple players on the server the script doesnt detect that the _playerID is stored in the array and so just spawns the player their vehicle - thus ignoring that they already have spawned and NOT packed up their vehicle!

BUT THERES MORE - after that first time it errors out, from then on it works fine again!!!!!! 

Has anyone else come across issues with arrays and not detecting that something is located in that array?  I know its case sensitive but its only numbers so thats not the issue. 


I have the same issue with another script where I limit what the trader will buy off a player by checking item against an array of all the items that specific trader is allowed to sell. in that scenario the odd classname is not detected as being allowed to be sold even tho its right there with all the others.


Just issues with arrays maybe? or better ways to check arrays?


Cheers guys


Edited by happydayz

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.