SA-MP Forums Archive
Gang Zone - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Gang Zone (/showthread.php?tid=157512)



Gang Zone - shoru93 - 06.07.2010

So lets say that I already have a gang zone definied, it shows the zone on map and runs perfect.
But how to make, when I enter in that zone to say" Youre entered in zone" ?


Re: Gang Zone - Carlton - 06.07.2010

Use the IsPlayerInArea function which is below. ( I sorta edited it for you )

pawn Code:
public IsPlayerInArea(playerid, Float:maxx, Float:maxy, Float:minx, Float:miny)
{
   new Float:x, Float:y, Float:z;
   GetPlayerPos(playerid, x, y, z);
   if(x < maxx && y < maxy  && x > minx && y > miny) return 1;
   return 0;
}



Re: Gang Zone - shoru93 - 06.07.2010

D:\Games\GRANDT~1\GTASHOT\GAMEMO~1\gtashot.pwn(295 ) : warning 235: public function lacks forward declaration (symbol "IsPlayerInArea")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.


Re: Gang Zone - Carlton - 06.07.2010

Change 'public' to 'stock'


Re: Gang Zone - shoru93 - 06.07.2010

and if there are many gang zones, for example if i enter in red zone say youve entered in red zone and if green, you ve entered green


Re: Gang Zone - Antonio [G-RP] - 06.07.2010

By telling him to change it to stock, you aren't teaching him WHAT that error means..


Re: Gang Zone - Carlton - 06.07.2010

Quote:
Originally Posted by Antonio [G-RP]
View Post
By telling him to change it to stock, you aren't teaching him WHAT that error means..
Jeez, you came back, the forum was better without your useless posts, just to increase your post count. But whatever, i'm not here posting to watch your idiotic comments.

Anyway, back to the topic. All you need to do is set a timer and check if the player is in the area, here is a snippet.

pawn Code:
new ZoneScriptData[MAX_PLAYERS][2];

public OnPlayerConnect(playerid) {
    ZoneScriptData[playerid][0] = -1;
    ZoneScriptData[playerid][1] = SetTimerEx(playerid, "CheckZone", 1000, 1, "i", playerid);
    return 1;
}

forward CheckZone(playerid);
public CheckZone(playerid) {
    if(IsPlayerInArea(MyGangZoneCoordinates)) // Red zone.
    {
         GameTextForPlayer(playerid, "You're in the red zone", 3000, 5);
         ZoneScriptData[playerid][0] = 1; // Redzone.
    }
    else if(IsPlayerInArea(MyGangZoneCoordinates)) // Red zone.
    {
         GameTextForPlayer(playerid, "You're in the green zone", 3000, 5);
         ZoneScriptData[playerid][0] = 2; // Greenzone.
    }
}

public OnPlayerDisconnect(playerid) {
    KillTimer(ZoneScriptData[playerid][1]);
}



Re: Gang Zone - shoru93 - 06.07.2010

D:\Games\GRANDT~1\GTASHOT\GAMEMO~1\gtashot.pwn(251 ) : error 035: argument type mismatch (argument 1)
D:\Games\GRANDT~1\GTASHOT\GAMEMO~1\gtashot.pwn(542 ) : error 010: invalid function or declaration
D:\Games\GRANDT~1\GTASHOT\GAMEMO~1\gtashot.pwn(543 ) : warning 235: public function lacks forward declaration (symbol "CheckZone")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.


Re: Gang Zone - shoru93 - 06.07.2010

D:\Games\GRANDT~1\GTASHOT\GAMEMO~1\gtashot.pwn(251 ) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.





ZoneScriptData[playerid][1] = SetTimerEx(playerid, "CheckZone", 1000, 1, "i", playerid);


Re: Gang Zone - Carlton - 06.07.2010

Quote:
Originally Posted by shoru93
View Post
D:\Games\GRANDT~1\GTASHOT\GAMEMO~1\gtashot.pwn(251 ) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Post the line of the error.