26.10.2010, 21:20
Hello,
i am wondering if its possible to have a expanding index with enums.. the reason for this is because this is what im trying to do:
---
I am making a car ownership system with mysql and i plan to store the cars in a enum. In the server each player can have up to 5 cars which they own, although they can only have a maximum of 1 car spawned at a time (Or they can have 0 cars spawned..and have them all "parked")... I want to store the cars in a enum like "CarStats[carid][cStat]" or maybe "CarStats[playerid][cStat]", i think the second one would work... however i want to make it so if you dont park you car (despawn it) before u log out, your car will stay there... so this rules out the [playerid] section...so i need to use carid? Now the carid would probably depend on which ones are taken already, so when i load the car into the script, i would do like:
So now i would know this enum is free and i would put all the data into there...
But now, i am at a dilemma for what size the enum should be.... I dont want to make it huge because it would mean that is wasted space.. and if its too small then it mean eventually a car will try to spawn but there would be no free spaces! so..if i cant expand the size of it.. the only option would be to do this..
Does anyone know what i can do here?
---
i am wondering if its possible to have a expanding index with enums.. the reason for this is because this is what im trying to do:
---
I am making a car ownership system with mysql and i plan to store the cars in a enum. In the server each player can have up to 5 cars which they own, although they can only have a maximum of 1 car spawned at a time (Or they can have 0 cars spawned..and have them all "parked")... I want to store the cars in a enum like "CarStats[carid][cStat]" or maybe "CarStats[playerid][cStat]", i think the second one would work... however i want to make it so if you dont park you car (despawn it) before u log out, your car will stay there... so this rules out the [playerid] section...so i need to use carid? Now the carid would probably depend on which ones are taken already, so when i load the car into the script, i would do like:
pawn Код:
new carid;
for(new i = 0; i<INDEX_SIZE_OF_ENUM; i++){
if(CarStats[i][cModel] == 0){ carid = i; continue; }
}
But now, i am at a dilemma for what size the enum should be.... I dont want to make it huge because it would mean that is wasted space.. and if its too small then it mean eventually a car will try to spawn but there would be no free spaces! so..if i cant expand the size of it.. the only option would be to do this..
pawn Код:
new carid;
carid = 9999;
for(new i = 0; i<INDEX_SIZE_OF_ENUM; i++){
if(CarStats[i][cModel] == 0){ carid = i; continue; }
}
if(carid == 9999) return SendClientMessage(playerid, COLOR, "Server cannot support any more vehicles..pleas try again later");
---