Can this be done better? - 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: Can this be done better? (
/showthread.php?tid=416637)
Can this be done better? -
Gladium - 17.02.2013
Aight so I wanted to give cop a sight, so if someone does a crime inside the sight, their wanted level will increment.
I did it likes this, but I don't think this is very efficient since I can't really make different kinds of areas.
Using Incognito's streamer btw.
pawn Код:
new Copsight[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
DestroyDynamicArea(Copsight[playerid]);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerInterior(playerid,0);
TogglePlayerClock(playerid,1);
if(playerTeam[playerid] == TEAM_POLICE)
{
SetPlayerTeam(playerid,0);
SetPlayerColor(playerid,COLOR_BLUE);
Copsight[playerid] = CreateDynamicCircle(2495.5669, -1687.1925, 40,-1, -1, -1);
AttachDynamicAreaToPlayer(Copsight[playerid], playerid);
}
if(playerTeam[playerid] == TEAM_CIVILIAN)
{
SetPlayerTeam(playerid,1);
SetPlayerColor(playerid,COLOR_WHITE);
}
}
and the increase
if(IsPlayerInAnyDynamicArea(playerid) == 1){SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);}
Re: Can this be done better? -
AndreT - 17.02.2013
You needn't create a dynamic area (although very good thinking), that's a bit overcomplicating.
What you could do when someone commits a crime is loop through all policemen and use IsPlayerInRangeOfPoint.