SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/06/2020, 08:08 PM   #1
makemoneynotfriends
Big Clucker
 
Join Date: Jan 2020
Location: Egypt
Posts: 120
Reputation: 3
Default onplayerenterdynamicarea

PHP Code:
public OnPlayerEnterDynamicArea(playeridareaid)
{
   for (new 
isizeof captureZonei++)
    {
        if (
areaid == captureZone[i][E_CAPTURE_ZONE_CP])
        {

            if (
captureZone[i][E_CAPTURE_ZONE_ATTACKER] == INVALID_PLAYER_ID)
            {
                if ((
GetPlayerTeam(playerid) >= && GetPlayerTeam(playerid) < sizeof TEAM) && TEAM[GetPlayerTeam(playerid)][E_TEAM_VALID] && GetPlayerTeam(playerid) != captureZone[i][E_CAPTURE_ZONE_OWNER]) // here the team ids play its role, we check the index is valid - The second part is if whether the player isn't of team that zone owner is
                
{
                    
captureZone[i][E_CAPTURE_ZONE_ATTACKER] = playerid;
                    
captureZone[i][E_CAPTURE_ZONE_PLAYERS_IN_ZONE] = 1;
                    
captureZone[i][E_CAPTURE_ZONE_COUNTDOWN] = 0;
                    
KillTimer(captureZone[i][E_CAPTURE_ZONE_TIMER]);
                    
captureZone[i][E_CAPTURE_ZONE_TIMER] = SetTimerEx("OnCaptureZoneUpdate"1000true"i"i);

                    
GangZoneFlashForAll(captureZone[i][E_CAPTURE_ZONE_GANGZONE], ALPHA(TEAM[GetPlayerTeam(playerid)][E_TEAM_COLOR], 100));

                    
SendClientMessage(playeridCOLOR_GREEN"Stay in the area to for "#CAPTURE_TIME" seconds to capture the zone.");

                
}
                else return 
1;
            }
            else if (
GetPlayerTeam(playerid) == GetPlayerTeam(captureZone[i][E_CAPTURE_ZONE_ATTACKER]))
            {

                
captureZone[i][E_CAPTURE_ZONE_PLAYERS_IN_ZONE]++;

            }

            
PlayerTextDrawShow(playeridcapturePlayerTextDraw[playerid]);
            
ShowPlayerProgressBar(playeridcapturePlayerBar[playerid]);
            return 
1;
        }
    }
            return 
1;

i want when someone enter the area and stays in it for +10seconds it will start caputring
makemoneynotfriends is offline   Reply With Quote
Old 01/07/2020, 05:59 PM   #2
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,077
Reputation: 126
Default Re: onplayerenterdynamicarea

And how are we supposed to know what's wrong with this pile of code?

Basically all you do here is drop your code, saying you want something without explaining what's wrong whatsoever. How are we supposed to help you like that?

Also, I don't think the callback you use would be the best method for this really.
I basically use this to check whether a player is inside an area:

pawn Code:
Terrect[TerritoryID] = CreateDynamicRectangle(MinX, MinY, MaxX, MaxY);

if(!IsPlayerInDynamicArea(playerid, Terrect[TerritoryID]))
     return SendSplitMessage(playerid, GREY, "ERROR: You have to be inside your base territory to access this menu.");
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 01/07/2020, 07:29 PM   #3
v1k1nG
Huge Clucker
 
v1k1nG's Avatar
 
Join Date: Feb 2018
Posts: 497
Reputation: 35
Default Re: onplayerenterdynamicarea

Quote:
Originally Posted by makemoneynotfriends View Post
i want when someone enter the area and stays in it for +10seconds it will start caputring
if

Quote:
Originally Posted by jasperschellekens View Post
IsPlayerInDynamicArea
use a timer

https://wiki.sa-mp.com/wiki/SetTimer
https://wiki.sa-mp.com/wiki/SetTimerEx

calling a function every second in which a variable gets increased.
When its value reaches 10, reset its value to 0 and start capturing.
__________________
My test server: 51.91.122.18:7778
My Discord contact: [SF]kAn3#9933
YT https://www.youtube.com/channel/UCrM...QtP2pczguqvppw
v1k1nG is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerEnterDynamicArea ShadowBlack Scripting Help 2 29/04/2018 02:48 PM
OnPlayerEnterDynamicArea OwlIT Scripting Help 5 04/04/2017 07:44 PM
CPU OnPlayerEnterDynamicArea Smith. Server Support 0 13/03/2015 07:34 PM
OnPlayerEnterDynamicArea help.. Youtube12 Scripting Help 0 09/03/2013 05:51 PM


All times are GMT. The time now is 07:57 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.