Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum
- {
- TYPE_NORMAL_VEHICLE,
- TYPE_DATABASE_VEHICLE
- }
- enum myVehicleEnum
- {
- vID,
- vModelID,
- Float:vX,
- Float:vY,
- Float:vZ,
- Float:vA,
- vColor1,
- vColor2,
- vRespawn,
- vSiren,
- vType
- }
- new MyVehicles[MAX_VEHICLES][myVehicleEnum];
- GetFreeSlot()
- {
- new id = -1;
- for(new i = 0; i < MAX_VEHICLES; i++)
- {
- if(MyVehicles[i][vUID] == 0)
- {
- id = i; // we found a free array slot
- break;
- }
- }
- return id;
- }
- CreateScriptedVehicle(modelid, Float:vX, Float:vY, Float:vZ, Float:vA, vColor1, vColor2, vRespawn = -1, vSiren = 0, vType = TYPE_NORMAL_VEHICLE)
- {
- new slot = GetFreeSlot();
- if(slot == -1) // no free slot found, don't create the vehicle and send a message
- {
- printf("Can't create vehicle, no free slot found!");
- }
- MyVehicles[slot][vModelID] = modelid;
- MyVehicles[slot][vX] = vX;
- MyVehicles[slot][vY] = vY;
- MyVehicles[slot][vZ] = vZ;
- MyVehicles[slot][vA] = vA;
- MyVehicles[slot][vColor1] = vColor1;
- MyVehicles[slot][vColor2] = vColor2;
- MyVehicles[slot][vRespawn] = vRespawn;
- MyVehicles[slot][vSiren] = vSiren;
- MyVehicles[slot][vType] = vType;
- if(MyVehicles[slot][vType] == TYPE_DATABASE_VEHICLE)
- {
- //Here you can insert the vehicle to the database, if it isn't already in it and you load those vehicles before you create normal ones in OnGameModeInit, for example:
- //LoadDatabaseVehicles();
- //...
- //CreateScriptedVehicle(...);
- //It should search for a free array id there and if you want to save, you only save those vehicles with vType = TYPE_DATABASE_VEHICLE
- }
- return CreateVehicle(modelid, vX, vY, vZ, vA, vColor1, vColor2, vRespawn, vSiren);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement