Liamsmith 1 Posted April 10, 2018 Hi, so i`m making an script where you press a button,eg f2, to spawn an vehicle. I was looking for help as you can easily spam it and blow the vehicles up. Also, i`m going to have multiple vehicles that will be able spawn and so if one vehicle spawns give it a delay before a different one is. Would be great if you died you had no delay and could spawn in a vehicle straight away. Vehicle_Spawn.sqf 0 = [] spawn { waitUntil {!isNull(findDisplay 46)}; (findDisplay 46) displayAddEventHandler ["KeyDown", { if(_this select 1 == 0x3C) then { createVehicle ["O_MRAP_02_F",player getPos [15,getDir player], [], 0, "CAN_COLLIDE"]; }; }]; }; Something Like This For The End Result 0 = [] spawn { waitUntil {!isNull(findDisplay 46)}; (findDisplay 46) displayAddEventHandler ["KeyDown", { if(_this select 1 == 0x3C) then { createVehicle ["O_MRAP_02_F",player getPos [15,getDir player], [], 0, "CAN_COLLIDE"]; }; }]; }; 0 = [] spawn { waitUntil {!isNull(findDisplay 46)}; (findDisplay 46) displayAddEventHandler ["KeyDown", { if(_this select 1 == 0x3C) then { createVehicle ["O_MRAP_02_F",player getPos [15,getDir player], [], 0, "CAN_COLLIDE"]; }; }]; }; --------------------------- Update when i spawn in the ifrits 2 spawn so they blow up. Share this post Link to post Share on other sites
beno_83au 1369 Posted April 10, 2018 Replace "CAN_COLLIDE" with "NONE", or any of the other options depending on your needs. Have a look at the alternative syntax - createVehicle - and look at what is said about "CAN_COLLIDE". Share this post Link to post Share on other sites
Liamsmith 1 Posted April 11, 2018 Out of interest how could i pause the script so the vehicle is spam spawn and lags everyone out. Thanks Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 11, 2018 3 minutes ago, Liamsmith said: Out of interest how could i pause the script so the vehicle is spam spawn and lags everyone out. Thanks Doubt you will get an answer to that, since it disrupts gameplay. Cheers Share this post Link to post Share on other sites
Liamsmith 1 Posted April 11, 2018 is there any work around? Share this post Link to post Share on other sites
beno_83au 1369 Posted April 11, 2018 Do you mean you want to avoid people spamming the script? Because your question translates as you wanting to lag everyone out. 1 Share this post Link to post Share on other sites
Liamsmith 1 Posted April 11, 2018 Yes, is there anyway to rework the script so you can only spawn a vehicle once every life time or anything just to stop spamming it. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 11, 2018 2 hours ago, Liamsmith said: Yes, is there anyway to rework the script so you can only spawn a vehicle once every life time or anything just to stop spamming it. You could restrict it to only allow spawning once every n seconds, but a better approach would be to allow spawning only if the player is a certain distance away from the last spawned vehicle. Something like this: 0 = [] spawn { waitUntil {!isNull(findDisplay 46)}; (findDisplay 46) displayAddEventHandler ["KeyDown", { _lastVehPos = player getVariable ["TAG_fnc_lastSpawnedVehPos",[0,0,0]]; if(_this select 1 == 0x3C AND player distance _lastVehPos > 15) then { _veh = createVehicle ["O_MRAP_02_F",player getPos [15,getDir player], [], 0, "NONE"]; player setVariable ["TAG_fnc_lastSpawnedVehPos",getposATL _veh]; }; }]; }; Cheers Share this post Link to post Share on other sites
Liamsmith 1 Posted April 11, 2018 23 minutes ago, Grumpy Old Man said: You could restrict it to only allow spawning once every n seconds, but a better approach would be to allow spawning only if the player is a certain distance away from the last spawned vehicle. Something like this: 0 = [] spawn { waitUntil {!isNull(findDisplay 46)}; (findDisplay 46) displayAddEventHandler ["KeyDown", { _lastVehPos = player getVariable ["TAG_fnc_lastSpawnedVehPos",[0,0,0]]; if(_this select 1 == 0x3C AND player distance _lastVehPos > 15) then { _veh = createVehicle ["O_MRAP_02_F",player getPos [15,getDir player], [], 0, "NONE"]; player setVariable ["TAG_fnc_lastSpawnedVehPos",getposATL _veh]; }; }]; }; Cheers When i spawn in vehicles 2 spawn instead of 1. The anitspam is perfect now. Share this post Link to post Share on other sites