Random Server Events
#1

Hello, I was hoping somebody could help me out and point me in the right direction with how I could accomplish this.

I've spent a bit of time trying this myself before coming for help but just can't get it to work, What I'm trying to do is create random RP events at a random time between every 15 - 60 minutes for example for my Fire Department faction.
Example: I want to code in a bunch of coordinates that will be randomly selected to use and there be an automatic 911 call for that location for a fire for the fire fighters, And I'd like to use a check with GetPlayerPos(); and IsPlayerInRangeOfPoint(); to check if a fireman has actually responded to the call and only then will a timer start and once that timer is done the call clears.

If I could just get the barebones things needed or somebody tell me how I should do it, I'd rather get pointed in the right direction than just have the code handed to me so I can learn it.
Thank you.
Reply
#2

Havent tested the code and probably wouldnt work, I wrote it on pastebin lol

PHP код:
//Top of the script
new Float:RandomFire[][4] =
{
    {-
2796.98541224.818020.5429192.0335},
    {-
2454.2170503.875930.0790267.2932},
    {-
2669.7322, -6.08746.132889.8853}
};
//gamdemodeinit
new MyRandomTimer randomEx(600000-3600000); //10-60 minutes
SetTimer("SetRoleplayEvent",MyRandomTimer,true); // set false if u want the event to occur only once
//function
forward SetRoleplayEvent();
public 
SetRoleplayEvent() {
    new 
rand random(sizeof(RandomFire)),string[64],PlayerPosNow[3];
    
CreateExplosion(RandomFire[rand][0], RandomFire[rand][1],RandomFire[rand][2], 1210.0);
    foreach(new 
i:Player) {
        
GetPlayerPos(i,PlayerPosNow[0],PlayerPosNow[0],PlayerPosNow[0]);
        if(
IsPlayerInRangeOfPoint(i,20,PlayerPosNow[0],PlayerPosNow[0],PlayerPosNow[0])) { //if there is anyone near the position
            
format(string,sizeof(string),"Explosion occured at %0.2F %0.2F %0.2F",RandomFire[rand][0], RandomFire[rand][1],RandomFire[rand][2]);
            
SendPoliceMessage(string); //change this to your PD message function
        
}
    }
    return 
true;

But just an example of random explosion.
Reply
#3

Thank you so much man, This is enough to point me in the right direction. I really appreciate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)