Home » Renegade Discussions » Mod Forum » How to Turn the Ped on after a specific time
Re: How to Turn the Ped on after a specific time [message #451261 is a reply to message #451244] |
Thu, 11 August 2011 11:12 |
|
Jerad2142
Messages: 3812 Registered: July 2006 Location: USA
Karma:
|
General (3 Stars) |
|
|
iRANian wrote on Thu, 11 August 2011 07:45 | It's impossible to crash the FDS or set off multiple timers when the time runs every 0.1 seconds but okay.
|
Course timers won't crash FDS, I'm just trying to point out that its more efficient to use two 128 length arrays (for a total of 0.000244140625 megabytes of ram usage) rather than have the CPU do a bunch of unnecessary work that can simply be avoided by using a function that triggers on exactly what you want. In addition, if the code was complex enough inside these timer calls it could bog down the FDS (granted this isn't even close to being able to do that, but I'm just trying to make a point).
iRANian wrote on Thu, 11 August 2011 07:45 |
My script checks if the guy has the beacons before doing anything so it can't crash when they don't have any weapons
|
When you call this code.
const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if (strcmp(currentweapon, "CnC_Weapon_NukeBeacon_Player") == 0
It Get_Current_Weapon gets what weapon your currently holding, you need to check if currentweapon is null before you use it otherwise stricmp will crash (guess I'm not sure about strcmp but I'd assume it's the same beings stricmp is built off of it). Furthermore, if you aren't holding a beacon (which is what your checking for (note, !_stricmp = match, _stricmp = different, and yes I know that might seem backward when you think of logical comparisons, but that's how it works)) so if you don't have a beacon in your hands, it won't be removed. Thus, the only time it can be removed is when you switch it into your hands, at which point you'll be left with empty hands, and from my experience that does a pretty good job crashing the server. The easy way to fix this is by switching to another gun if the player is currently holding the weapon you want to remove before you remove it, if they aren't holding it you just remove it like normal.
iRANian wrote on Thu, 11 August 2011 07:45 |
unless there's an issue with Get_Total_Bullets().
|
I'm pretty sure its fine, I just do the has weapon check out of habit. Pretty sure if you don't have the weapon it returns 0 just fine.
iRANian wrote on Thu, 11 August 2011 07:45 |
The deactivating is easy to add with a second script that destroys the zone object after an hour, or by using 1 as the timer number number and in ::Timer_Expired() do a check if the number is 1 else do the code I shown, when the timer is 1 use Destroy_Script().
|
Beings you're not using player ID's for zone enter you definitely could do it that way, but by not checking if it's a star that entered, or grabbing the ID of their enterer, you risk applying this script to every object that enters the zone (whether it be Human, vehicle, or an object attached to a human/vehicle). Also, you don't need to remove beacons before you grant them, beings they have a max ammo count of 1 you won't be able to give the player 2.
iRANian wrote on Thu, 11 August 2011 07:45 |
How does the script zone logic handle people dying while inside them, does it trigger ::Exited() and if it does, it trigger it before or after respawning?
|
When you die in a script zone you don't exit until your char is "Destroyed" (what happens after the fade effect). It happens right before destroyed is called, just like enter happens just after created is called if it's created inside a zone.
...
Although your code does have the potential to do something slightly different for the same result. Beings your script fires over and over again, instead of removing the players gun, you could check if they were holding a beacon, if they are you'd do something like this;
Commands->Select_Weapon(player,"");
Commands->Select_Weapon(player,"beaconName");
By doing that, the player keeps the beacon but can't use it. This is because when you switch between nothing and then to a weapon it triggers the exited/enter sequences of the beacon which means you have to wait the weapon switch time before you can use it; beings your script keeps firing, you'd never be able to use it while in the zone.
Note: You'd only want to call that code if they already hand the beacon in their hands, obviously, you don't want to force switch them to the beacon if they aren't holding it.
Note: If you did do it that way, make sure the empty select is always called first and immanently following by a select with a weapon, otherwise the games code has time to jump across a player with no weapon, and once again, that seems to make the game like to crash.
Visit Jerad's deer sweat shop
|
|
|
|
|
How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Thu, 28 April 2011 12:45
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: Hex on Thu, 28 April 2011 15:19
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: zunnie on Sat, 07 May 2011 06:20
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Wed, 10 August 2011 13:33
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Wed, 10 August 2011 13:57
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Thu, 11 August 2011 06:45
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Thu, 11 August 2011 11:24
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Thu, 11 August 2011 12:56
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Thu, 11 August 2011 14:08
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Thu, 11 August 2011 22:37
|
|
|
Re: How to Turn the Ped on after a specific time
|
|
|
Re: How to Turn the Ped on after a specific time
By: iRANian on Thu, 11 August 2011 22:52
|
|
|
Re: How to Turn the Ped on after a specific time
|
Goto Forum:
Current Time: Wed Dec 18 15:38:21 MST 2024
Total time taken to generate the page: 0.00969 seconds
|