12.12.2017, 13:06
Hello, in my GM I have this problem: the vehicles are not destroyable if the player is out from it, but only if he is in.
Is it possible to make the vehicle destroyable also without player in?
This is my GM script
Is it possible to make the vehicle destroyable also without player in?
This is my GM script
Код:
stock CreateVehicleEx(playerid, modelid) // With this feature we can create vehicles in all our indent usage CreateVehicleEx(playerid, modelid); { new Float:pos[4]; // Create float 4 slots to obtain pos_x, pos_y, pos_z and GetVehicleZangle If you are in a vehicle the user. /*if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // obtain getplayerstate (if this driver).. { GetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]); // Obtain position in the floats. GetVehicleZAngle(GetPlayerVehicleID(playerid), pos[3]); // obtan angle vehicle. DestroyVehicle(GetPlayerVehicleID(playerid)); // Destroy last vehicle created and continue function. }*/ GetPlayerPos(playerid, pos[0], pos[1], pos[2]); // obtain position in the floats. GetPlayerFacingAngle(playerid, pos[3]); // obtain angle playerid and continue function.. //if(vehicle_spawn[playerid] != 0) DestroyVehicle(vehicle_spawn[playerid]); // if variable is greater than 0 destroy the last vehicle created. vehicle_spawn[playerid] = CreateVehicle(modelid, pos[0], pos[1], pos[2], pos[3], -1, -1, -1); // Create vehicle in pos obtain the floats. LinkVehicleToInterior(vehicle_spawn[playerid], GetPlayerInterior(playerid)); // Changes inside the vehicle to which the user is located. SetVehicleVirtualWorld(vehicle_spawn[playerid], GetPlayerVirtualWorld(playerid)); // Change the world the vehicle spawn to which you will find a player PutPlayerInVehicle(playerid, vehicle_spawn[playerid], 0); // The playerid enters the vehicle and driver. SetVehicleZAngle(vehicle_spawn[playerid], pos[3]); // Set angle te obtain float. return true; } stock IsNumeric(const string[]) // function comprobate is numeric { for (new i = 0, j = strlen(string); i < j; i++) { if (string[i] > '9' || string[i] < '0') return 0; } return true; } stock GetModelVehicle(vname[]) // fuction getmodelvehicle in the names { for(new i = 0; i < 211; i++) { if(strfind(NameVehicles[i], vname, true) != -1) return i + 400; } return false; }
Код:
COMMAND:car(playerid, params[]) { if(IsNumeric(params)) // if is numeric params. { if(sscanf(params, "i", params[0])) return SendClientMessage(playerid, -1, "Usage: /car <name/modelid>."); if(params[0] < 400 || params[0] > 611) return SendClientMessage(playerid, -1, "modelid invalid, usage: /car <modelid 400-611>."); CreateVehicleEx(playerid, params[0]); } else // not is numeric { new name_vehicle[30], i_create_vehicle; if(sscanf(params, "s[30]", name_vehicle)) return SendClientMessage(playerid, -1, "Usage: /car <name/modelid>."); i_create_vehicle = GetModelVehicle(name_vehicle); if(i_create_vehicle < 400 || i_create_vehicle > 611) return SendClientMessage(playerid, -1, "name invalid, usage: /car <name correct>."); CreateVehicleEx(playerid, i_create_vehicle); } return true; // Do something }