04.01.2014, 17:28
Quote:
Dude, I'm not a newbie I even made using your include a dynamic system please read the post and test the code the server crashed when the missile exploded and I have the latest version already..
I hope you will give me your attention.. Thanks |
pawn Код:
#define SAMInfo L_SAMData
public LordzSAMTimer()
{
for(new i; i < MAX_LSAMS; i++)
{
if(L_SAMData[i][L_SAMCreated])
{
for(new a; a < MAX_PLAYERS; a++)
{
if(!IsPlayerConnected(a)) continue;
if(!IsPlayerInRangeOfPoint(a, SAMInfo[i][L_SAMRange], SAMInfo[i][L_SAMX], SAMInfo[i][L_SAMY], SAMInfo[i][L_SAMZ])) continue;
if(L_SAM_ExceptionalPlayer[a][i]) continue;
if(MissileInProgress[a]) continue;
GetPlayerPos(a, L_SAMPlayerPos[a][0], L_SAMPlayerPos[a][1], L_SAMPlayerPos[a][2]);
new p_missileobj = CreateObject(345, SAMInfo[i][L_SAMX], SAMInfo[i][L_SAMY], SAMInfo[i][L_SAMZ], 0.0, 0.0, 0.0, 300.0);
PlayerMissile[a] = p_missileobj;
L_SAMMissileObject[p_missileobj] = 1;
L_SAMMissilePower[p_missileobj] = SAMInfo[i][L_SAMPower];
L_SAMMissileProgress[p_missileobj] = a;
MoveObject(p_missileobj, L_SAMPlayerPos[a][0], L_SAMPlayerPos[a][1], L_SAMPlayerPos[a][2], SAMInfo[i][L_SAMSpeed]);
MissileInProgress[a] = true;
SetPlayerMapIcon(a, 99, SAMInfo[i][L_SAMX], SAMInfo[i][L_SAMY], SAMInfo[i][L_SAMZ], 0, 0x660000FF);
L_SAMMissileMarker[a] = SetTimerEx("L_SAMUpdateMapIcon", 250, true, "ii", a, i);
}
}
}
return 1;
}
forward L_SAMUpdateMapIcon(playerid, samid);
public L_SAMUpdateMapIcon(playerid, samid)
{
if(!MissileInProgress[playerid]) return KillTimer(L_SAMMissileMarker[playerid]);
new Float:X, Float:Y, Float:Z, Float:oX, Float:oY, Float:oZ;
if(SAMInfo[samid][L_SAMFollow] == true)
{
GetPlayerPos(playerid, X, Y, Z);
GetObjectPos(PlayerMissile[playerid], oX, oY, oZ);
if(IsPlayerInRangeOfPoint(playerid, 10.0, oX, oY, oZ))
{
L_SAMMissileStopped[PlayerMissile[playerid]] = false;
return CallLocalFunction("OnObjectMoved", "i", PlayerMissile[playerid]);
}
else
{
L_SAMMissileStopped[PlayerMissile[playerid]] = true;
L_SAMAssignedSpeed[PlayerMissile[playerid]] = SAMInfo[samid][L_SAMSpeed]+randomEx(2,20); //Increasing the speed!
StopObject(PlayerMissile[playerid]);
MoveObject(PlayerMissile[playerid], X, Y, Z, L_SAMAssignedSpeed[PlayerMissile[playerid]]);
}
}
GetObjectPos(PlayerMissile[playerid], X, Y, Z);
SetPlayerMapIcon(playerid, 99, X, Y, Z, 0, 0x660000FF);
return 1;
}
public OnObjectMoved(objectid)
{
if(L_SAMMissileObject[objectid] == 1)
{
if(!L_SAMMissileStopped[objectid])
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(objectid, X, Y, Z);
switch(L_SAMMissilePower[objectid])
{
case 0: CreateExplosion(X+4.0, Y+4.0, Z, 2, 12.0);
case 1: CreateExplosion(X+4.0, Y+4.0, Z, 7, 12.0);
case 2:
{
CreateExplosion(X+8.0,Y, Z, 7, 10.0);
CreateExplosion(X-8.0,Y, Z, 7, 10.0);
CreateExplosion(X, Y+8.0,Z, 7, 10.0);
CreateExplosion(X, Y-8.0,Z, 7, 10.0);
}
case 3:
{
new Float:range = 8.0;
CreateExplosion(X+range,Y, Z, 6, 10.0);
CreateExplosion(X-range,Y, Z, 6, 10.0);
CreateExplosion(X, Y+range,Z, 6, 10.0);
CreateExplosion(X, Y-range,Z, 6, 10.0);
CreateExplosion(X+range,Y+range,Z, 6, 10.0);
CreateExplosion(X-range,Y+range,Z, 6, 10.0);
CreateExplosion(X-range,Y-range,Z, 6, 10.0);
}
}
DestroyObject(objectid);
RemovePlayerMapIcon(L_SAMMissileProgress[objectid], 99);
L_SAMMissileObject[objectid] = 0;
L_SAMMissilePower[objectid] = 0;
MissileInProgress[L_SAMMissileProgress[objectid]] = false;
L_SAMMissileProgress[objectid] = -1;
}
}
CallLocalFunction("OnObjectMoved", "i", objectid);
return 1;
}