SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/04/2018, 09:22 PM   #1
kovac
Huge Clucker
 
kovac's Avatar
 
Join Date: Mar 2018
Posts: 280
Reputation: 3
Default Zones problem

PHP Code:
enum eZone
{
    
Name[30],
    
Float:MinX,
    
Float:MinY,
    
Float:MaxX,
    
Float:MaxY,
    
FactionID
};
new 
ZoneInfo[][eZone] = {
    {
"z1"1103.9514,-2080.3044,1210.2815,-2001.2170,0},
    {
"z2"1571.3643,-2324.0732,1802.9613,-2249.9004,0},
    {
"z3"1078.2103,-1565.0592,1180.5872,-1423.2968,0},
    {
"z4"2447.8896,-1692.6818,2527.0767,-1637.6949,0},
    {
"z5"2181.0635,-1212.8799,2249.4675,-1159.3541,0},
    {
"z6"808.7136,-1128.7974,943.6923,-1059.9695,0},
    {
"z7"1871.7330,-1238.4614,2037.9884,-1159.2889,0}
};
new 
ZoneID[sizeof(ZoneInfo)]; 
PHP Code:
    //OnPlayerSpawn
for(new i=0sizeof(ZoneInfo); i++)// ZONES
    
{
        
GangZoneShowForPlayer(playeridZoneID[i], 0xFF000088); // GetTeamZoneColor(ZoneInfo[i][zTeam])
    

First zone doesn't show...


and when I use this

PHP Code:
    for(new i=0sizeof(ZoneInfo); i++)
    {
        if(
IsPlayerInZone(playeridi))
        {
            
GangZoneFlashForAll(ZoneID[i], COLOR_BROWN);
        }
    } 
totally different zone flash

this is how I create them
PHP Code:
    for(new i=0sizeof(ZoneInfo); i++)
    {
        
GangZoneCreate(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY]);
        
ZoneID[i] = CreateDynamicRectangle(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY], 00, -1);
    } 
what do I do?
kovac is offline   Reply With Quote
Old 16/04/2018, 10:45 PM   #2
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,382
Reputation: 437
Default Re: Zones problem

Quote:
Originally Posted by kovac View Post
this is how I create them
PHP Code:
    for(new i=0sizeof(ZoneInfo); i++)
    {
        
GangZoneCreate(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY]);
        
ZoneID[i] = CreateDynamicRectangle(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY], 00, -1);
    } 
what do I do?
The ZoneID should probably contain the Gang Zone ID, but you don't save the Gang Zone ID at all, you're saving the Dynamic Area ID to the ZoneID array.

As a result it tries to flash the ID of the Dynamic Area and not the Gang Zone ID - which is probably still a valid ID, but a totally different one than it's supposed to be, which is why it is not showing the first one and flashing the wrong one.

If you need the Dynamic Area IDs as well, you should add another array (something like "ZoneAreaID") and assign the Dynamic Area ID to that, and the Gang Zone ID to the ZoneID array.
NaS is online now   Reply With Quote
Old 17/04/2018, 11:13 AM   #3
kovac
Huge Clucker
 
kovac's Avatar
 
Join Date: Mar 2018
Posts: 280
Reputation: 3
Default Re: Zones problem

Can you please give me the code? Because I'm totally confused what gang zone, dynamic area and dynamic rectangle is and why do I need all of that..
kovac is offline   Reply With Quote
Old 17/04/2018, 11:40 AM   #4
JesterlJoker
Huge Clucker
 
Join Date: Apr 2015
Location: Cagayan de Oro, Philippines
Posts: 263
Reputation: 24
Default Re: Zones problem

This will explain what the Dynamic ones are
Streamer

and this will explain gangzones
gangzones

Then for my explanation
Gangzones is a native in samp which will have a different id

for example the first Gangzone Create will have an ID of 0

then the first CreateDynamicRectangle will also have an ID of 0

with that if you create another Gangzone then its ID will be 1


in code
PHP Code:
GangZoneCreate(Float:minxFloat:minyFloat:maxxFloat:maxy); // ID 0
GangZoneCreate(Float:minxFloat:minyFloat:maxxFloat:maxy); // ID 1

CreateDynamicRectangle(Float:minxFloat:minyFloat:maxxFloat:maxyworldid = -1interiorid = -1playerid = -1); // ID 0 
Then as an example ID 0 on gangzone is in a different location then ID 1 will be the same place as ID 0 in dynamic rectangle
if you try to change the color using dynamic rectangle's ID then gangzone ID 0 will be changed since it has the same ID as dynamic ID

Why are they different?

Since streamer uses its own plugin and uses its own counter
__________________
My Projects:
JesterlJoker is offline   Reply With Quote
Old 18/04/2018, 10:36 AM   #5
kovac
Huge Clucker
 
kovac's Avatar
 
Join Date: Mar 2018
Posts: 280
Reputation: 3
Default Re: Zones problem

Thank you, but I'm still confused which part of my code should I change
kovac is offline   Reply With Quote
Old 18/04/2018, 10:50 AM   #6
TitoRayne
Big Clucker
 
Join Date: May 2017
Posts: 149
Reputation: 1
Default Re: Zones problem

Quote:
Originally Posted by kovac View Post
Thank you, but I'm still confused which part of my code should I change
Maybe this part.
PHP Code:
for(new i=0sizeof(ZoneInfo); i++) 
    { 
        
GangZoneCreate(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY]); 
        
ZoneID[i] = CreateDynamicRectangle(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY], 00, -1); 
    } 
TitoRayne is offline   Reply With Quote
Old 18/04/2018, 12:10 PM   #7
JesterlJoker
Huge Clucker
 
Join Date: Apr 2015
Location: Cagayan de Oro, Philippines
Posts: 263
Reputation: 24
Default Re: Zones problem

You may still use both but you will need to change this
PHP Code:
for(new i=0sizeof(ZoneInfo); i++)  
    {  
        
GangZoneCreate(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY]);  
        
ZoneID[i] = CreateDynamicRectangle(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY], 00, -1);  
    } 
to this
PHP Code:
for(new i=0sizeof(ZoneInfo); i++)  
    {  
        
ZoneID[i] = GangZoneCreate(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY]);  
        
CreateDynamicRectangle(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY], 00, -1);  
    } 
and when you do something you'll have to do something about the zoneid now


or you can use only one of the function and from there make it work.
The changing colors is another story, since only Gangzone's has that, I think, never really tried to make Dynamic Areas change color though
__________________
My Projects:
JesterlJoker is offline   Reply With Quote
Old 18/04/2018, 12:15 PM   #8
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,382
Reputation: 437
Default Re: Zones problem

Quote:
Originally Posted by JesterlJoker View Post
You may still use both but you will need to change this
PHP Code:
for(new i=0sizeof(ZoneInfo); i++)  
    {  
        
GangZoneCreate(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY]);  
        
ZoneID[i] = CreateDynamicRectangle(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY], 00, -1);  
    } 
to this
PHP Code:
for(new i=0sizeof(ZoneInfo); i++)  
    {  
        
ZoneID[i] = GangZoneCreate(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY]);  
        
CreateDynamicRectangle(ZoneInfo[i][MinX], ZoneInfo[i][MinY], ZoneInfo[i][MaxX], ZoneInfo[i][MaxY], 00, -1);  
    } 
and when you do something you'll have to do something about the zoneid now


or you can use only one of the function and from there make it work.
The changing colors is another story, since only Gangzone's has that, I think, never really tried to make Dynamic Areas change color though
Dynamic Areas cannot change colors as they aren't visible. They are only existing server-side. So good luck with that.

You'll have to save both IDs, the dyn. Area ID and the Gang Zone ID in seperate Arrays (or even better, add another variable to the enumerator).


@OP: I suggest you learn some scripting basics. You're trying to make us fix a script you didn't even write yourself obviously.
NaS is online now   Reply With Quote
Old 18/04/2018, 12:37 PM   #9
JesterlJoker
Huge Clucker
 
Join Date: Apr 2015
Location: Cagayan de Oro, Philippines
Posts: 263
Reputation: 24
Default Re: Zones problem

Quote:
Originally Posted by NaS View Post
Dynamic Areas cannot change colors as they aren't visible. They are only existing server-side. So good luck with that.

You'll have to save both IDs, the dyn. Area ID and the Gang Zone ID in seperate Arrays (or even better, add another variable to the enumerator).


@OP: I suggest you learn some scripting basics. You're trying to make us fix a script you didn't even write yourself obviously.
Nas say the truth though, with enough reading you could understand this in one go as everyone who read did. We usually read documentations and help people out here who mostly have not read anything. They claim to be but when words from the documentations come out they tend not to understand.

We don't condemn people who used released scripts but you can't blame us if we become blunt at some point, pointing out you don't know things we do, which should have been easy, if you have read.
__________________
My Projects:
JesterlJoker 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
Zones problem Ananisiki Scripting Help 0 07/09/2013 04:19 PM
Zones Problem Hoss Help Archive 3 24/04/2011 07:24 PM
Zones Problem, Kyle Help Archive 0 19/10/2010 12:34 PM
Problem with zones Jochemd Help Archive 3 24/05/2010 03:35 PM
A little problem with gang zones (only create gang zones) CTCCoco Help Archive 4 20/02/2009 10:59 AM


All times are GMT. The time now is 01:27 PM.


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