SetVehicleParamsForPlayerEx hight size -
nico005 - 14.07.2010
Hi,
I utilise that on my gamemode with /lock and /unlock
new iVehicleObjective[MAX_PLAYERS][MAX_VEHICLES][2];
public OnVehicleStreamIn(vehicleid,forplayerid)
{
SetVehicleParamsForPlayer(vehicleid,forplayerid,iV ehicleObjective[forplayerid][vehicleid [0],iVehicleObjective[forplayerid][vehicleid][1]);
return 1;
}
stock SetVehicleParamsForPlayerEx(vehicleid, playerid, objective, doorslocked)
{
SetVehicleParamsForPlayer(vehicleid, playerid, objective, doorslocked);
iVehicleObjective[playerid][vehicleid][0] = objective;
iVehicleObjective[playerid][vehicleid][1] = doorslocked;
return 1;
}
Work, but my file size .pawn is 2500ko and .amx 10000 ko, if i remove VehicleObjective my amx size is 4500k. It's normally? Why? and there are not other solution?
Thanks
Re: SetVehicleParamsForPlayerEx hight size -
Grim_ - 14.07.2010
Well you're making an array with a 500 and 2000 and 2 sizes.
However, adding 5500k in file size, I doubt that is normal.
Re: SetVehicleParamsForPlayerEx hight size -
nico005 - 14.07.2010
yes, but I have in my GM > 60k lines, without that .amx file size is divised for 2. It is enormous, just for that. For ram memory... there are not a code optimized for that?
Re: SetVehicleParamsForPlayerEx hight size -
Simon - 14.07.2010
You can optimize the addition by about half by using a "flag".. you can use the bitwise and/or/not operators to do this:
pawn Код:
enum (<<=1)
{
FLAG_NONE,
FLAG_VEHICLE_LOCKED = 1,
FLAG_VEHICLE_OBJECTIVE
};
new iVehicleObjective[MAX_PLAYERS][MAX_VEHICLES];
// we could now do stuff like this:
iVehicleObjective[playerid][vehicleid] |= FLAG_VEHICLE_LOCKED; // add a locked flag
iVehicleObjective[playerid][vehicleid] |= FLAG_VEHICLE_OBJECTIVE; // add an objective flag
// we can "get" the values doing this
iVehicleObjective[playerid][vehicleid] & FLAG_VEHICLE_LOCKED // will be non-zero if set, zero if not set
iVehicleObjective[playerid][vehicleid] & FLAG_VEHICLE_OBJECTIVE // will be non-zero if set, zero if not set
//.. i'm not sure if the functions expect a "true"/"false" for the parameters, but you can convert the above to true/false like this example. You may not need to do this step so test without first, for simplicity:
(iVehicleObjective[playerid][vehicleid] & FLAG_VEHICLE_LOCKED == FLAG_VEHICLE_LOCKED) // will be a true/false result
(iVehicleObjective[playerid][vehicleid] & FLAG_VEHICLE_OBJECTIVE == FLAG_VEHICLE_OBJECTIVE)
// we can "unset" the values doing this
iVehicleObjective[playerid][vehicleid] &= ~FLAG_VEHICLE_LOCKED; // will remove the vehicle locked flag
iVehicleObjective[playerid][vehicleid] &= ~FLAG_VEHICLE_OBJECTIVE; // will remove the vehicle objective flag
You'll probably want to put these as functions rather than hacking around with this low level stuff all the time, it has not been tested on the server but it should work.
Also, make sure you set your MAX_VEHICLES and MAX_PLAYERS to the amount you have in your server. It will greatly decrease the size of your AMX (using your current implementation, you should be using 15625 kbytes of RAM -- if I've calculated that correctly
)..