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 #451224 is a reply to message #451200] |
Wed, 10 August 2011 20:59 |
|
Jerad2142
Messages: 3812 Registered: July 2006 Location: USA
Karma:
|
General (3 Stars) |
|
|
Here you go then.
void JMG_Prevent_Ped_Beacons_Time::Created(GameObject *obj)
{
for (int x = 0;x < 128;x++)
{
ion[x] = false;
nuke[x] = false;
}
Commands->Start_Timer(obj,this,Get_Float_Parameter("Time_Seconds"),1003943);
}
void JMG_Prevent_Ped_Beacons_Time::Entered(GameObject *obj, GameObject *enter)
{
int PlayerID = Get_Player_ID(enter);
if (!PlayerID)
return;
if (Has_Weapon(enter,"CnC_Weapon_IonCannonBeacon_Player") && Get_Current_Bullets(enter) > 0)
{
if (!Remove_Weapon_Safely(enter,"CnC_Weapon_IonCannonBeacon_Player","CNC_Weapon_Pistol_Player "))
return;
ion[PlayerID] = true;
}
if (Has_Weapon(enter,"CnC_Weapon_NukeBeacon_Player") && Get_Current_Bullets(enter) > 0)
{
if (!Remove_Weapon_Safely(enter,"CnC_Weapon_NukeBeacon_Player","CNC_Weapon_Pistol_Player "))
return;
nuke[PlayerID] = true;
}
}
void JMG_Prevent_Ped_Beacons_Time::Exited(GameObject *obj, GameObject *exit)
{
int PlayerID = Get_Player_ID(exit);
if (!PlayerID)
return;
if (ion[PlayerID])
Commands->Give_Powerup(exit,"CnC_POW_IonCannonBeacon_Player",false);
if (nuke[PlayerID])
Commands->Give_Powerup(exit,"CnC_POW_Nuclear_Missle_Beacon",false);
ion[PlayerID] = false;
nuke[PlayerID] = false;
}
void JMG_Prevent_Ped_Beacons_Time::Timer_Expired(GameObject *obj, int number)
{
if (number == 1003943)
{
for (int x = 1;x < 128;x++)
{
GameObject *Player = Get_GameObj(x);
if (!Player)
continue;
if (ion[x])
Commands->Give_Powerup(Player,"CnC_POW_IonCannonBeacon_Player",false);
if (nuke[x])
Commands->Give_Powerup(Player,"CnC_POW_Nuclear_Missle_Beacon",false);
}
Remove_Script(obj,"z_Prevent_Ped_Beacons_Time");
}
}
bool JMG_Prevent_Ped_Beacons_Time::Remove_Weapon_Safely(GameObject *obj,const char *WeaponName,const char *SelectWeapon)
{
const char *CurrentWeapon = Get_Current_Weapon(obj);
if (CurrentWeapon)
if (!_stricmp(CurrentWeapon,WeaponName))
{
if (Has_Weapon(obj,SelectWeapon))
{
Commands->Select_Weapon(obj,SelectWeapon);
Remove_Weapon(obj,WeaponName);
Commands->Select_Weapon(obj,SelectWeapon);
return true;
}
}
else
{
Remove_Weapon(obj,WeaponName);
return true;
}
return false;
}
ScriptRegistrant<JMG_Prevent_Ped_Beacons_Time> JMG_Prevent_Ped_Beacons_Time("JMG_Prevent_Ped_Beacons_Time","Time_Seconds=600000:float ");
class JMG_Prevent_Ped_Beacons_Time : public ScriptImpClass {
bool ion[128];
bool nuke[128];
void Created(GameObject *obj);
void Timer_Expired(GameObject *obj, int number);
void Entered(GameObject *obj, GameObject *enter);
void Exited(GameObject *obj, GameObject *exit);
bool Remove_Weapon_Safely(GameObject *obj,const char *WeaponName,const char *SelectWeapon);
};
But there you go beings you are so picky, a version that checks for ammo and does not give you a beacon if its empty, in addition, it does potentially 3,599 less useless checks in a 30 minute game per player in zone.
I will admit I did not really read though your original post, and though you called the timer originally from created instead of entered.
And yours still can crash the fds if the player/entering object has no weapon.
And will fail to do anything if they are not holding the beacon, and if they are the server can crash when it removes the beacon.
Also, if you could time jumping or walking in and out of the zone you could set off multiple copies of the timer that slowly flooding the server with more and more pointless checks.
Finally, your script doesn't deactivate after a certain amount of time, which was rather the point of this thread in the first place...
Visit Jerad's deer sweat shop
[Updated on: Wed, 10 August 2011 22:16] Report message to a moderator
|
|
|
|
|
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 13:09:08 MST 2024
Total time taken to generate the page: 0.00905 seconds
|