Originally Posted by chaosnz
Quote:
/************************************************** *****************************
Snow filterscript to simulate falling snow effects for SA:MP
SA:MP 0.3
Author: James "Jay" Wilkinson
irc.gtanet.com #Jay
irc.gtanet.com #ww3
irc.sa-mp.com #ww3
Copyright © Jay 2009
************************************************** *****************************/
#include <a_samp>
#define SNOW_OBJECT 354
#define SLOTS 200 // aka MAX_PLAYERS
#define MAX_SNOW 20
static snowObject[SLOTS][MAX_SNOW+1];
static snowActive[SLOTS];
public OnFilterScriptExit()
{
for(new i = 0; i < SLOTS; i++)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i))
continue;
DestroySnow(i);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(!IsPlayerNPC(playerid))
DestroySnow(playerid);
}
public OnPlayerSpawn(playerid)
{
CreateSnow(playerid);
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/bombs"))
{
for(new i=0; i <= MAX_PLAYERS; i++)
{
if(!snowActive[playerid])
{
CreateSnow(i);
SendClientMessage(i, 0xFFFFFFFF, "DANGER BOMBS ARE FALLING!");
}else{
DestroySnow(i);
SendClientMessage(i, 0xFFFFFFFF, "Bombs have been removed.");
}
}
return 1;
}
return 0;
}
stock CreateSnow(playerid)
{
if(GetPlayerState(playerid) == 0 || GetPlayerState(playerid) > 6)
return;
if(GetPlayerInterior(playerid) != 0)
return;
if(snowActive[playerid] == 1)
return;
snowActive[playerid] = 1;
new
Float,
Float:y,
Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 0; i < MAX_SNOW; i++)
{
snowObject[playerid][i] = CreatePlayerObject(playerid, SNOW_OBJECT, x, y , z , 0, 0, 0);
RecreateSnow(playerid, snowObject[playerid][i]);
}
}
stock DestroySnow(playerid)
{
snowActive[playerid] = 0;
for(new i = 0; i < MAX_SNOW; i++)
{
DestroyPlayerObject(playerid, snowObject[playerid][i]);
}
}
stock RecreateSnow(playerid, objectid)
{
if(snowActive[playerid] == 0)
return;
new
Float,
Float:y,
Float:z,
FloatbjX,
FloatbjY,
FloatbjZ;
GetPlayerPos(playerid, x, y, z);
// And before you ask, I use random twice because SA:MP's random sucks ass
new i = random(random(100));
if(i < 20)
{
SetPlayerObjectPos(playerid, objectid, x - random(random(2400)), y + random (random(2400)), z + random(70)+30);
}
else if(i >= 21 && i <= 30)
{
SetPlayerObjectPos(playerid, objectid, x + random(random(2400)), y + random (random(2400)), z + random(60)+40);
}
else if (i >= 31 && i < 40)
{
SetPlayerObjectPos(playerid, objectid, x + random(random(2400)), y - random (random(2400)), z + random(50)+50);
}
else
{
SetPlayerObjectPos(playerid, objectid, x + random(random(2400)), y + random (random(2400)), z + random(40)+60);
}
GetPlayerObjectPos(playerid, objectid, objX, objY, objZ);
MovePlayerObject(playerid, objectid, objX, objY, z, random(0.2)+0.4);
}
public OnPlayerObjectMoved(playerid, objectid)
{
new
Float,
Float:y,
Float:z,
FloatbjX,
FloatbjY,
FloatbjZ;
if(snowActive[playerid] == 0)
return 1;
for(new i = 0; i < MAX_SNOW; i++)
{
if(objectid == snowObject[playerid][i])
{
GetPlayerPos(playerid, x, y, z);
GetPlayerObjectPos(playerid, objectid, objX, objY, objZ);
CreateExplosion(objX,objY,z,6,0.5);
RecreateSnow(playerid, objectid);
return 1;
}
}
return 1;
}
|
|