Random Server Events - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random Server Events (
/showthread.php?tid=595473)
Random Server Events -
DevHarden - 03.12.2015
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.
Re: Random Server Events -
TwinkiDaBoss - 03.12.2015
Havent tested the code and probably wouldnt work, I wrote it on pastebin lol
PHP код:
//Top of the script
new Float:RandomFire[][4] =
{
{-2796.9854, 1224.8180, 20.5429, 192.0335},
{-2454.2170, 503.8759, 30.0790, 267.2932},
{-2669.7322, -6.0874, 6.1328, 89.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], 12, 10.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.
Re: Random Server Events -
DevHarden - 03.12.2015
Thank you so much man, This is enough to point me in the right direction. I really appreciate it.