SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/08/2012, 06:57 AM   #1
andrew2695
Big Clucker
 
Join Date: Oct 2010
Posts: 124
Reputation: 4
Default GetPlayer2DZone, Question custom zone names by VirtualWorlds

Hello, I'm using GetPlayer2DZone(playerid, zone[], len) and it's working fine but my question is how can I make custom zone names by Virtual Worlds?
My old code was this and it was working fine but I wanted to change because GetPlayer2DZone is better.
pawn Code:
stock ReturnPlayerZone(playerid)
{
    new playerzone[50] = "Unknown Location",
        AmmuInMarket[50] = "Ammunation In Market(LS)",
        AmmuInComeALot[50] = "Ammunation In Come-A-Lot",
        AmmuInBoneCounty[50] = "Ammunation In Bone County",
        AmmuInFortCarson[50] = "Ammunation In Fort Carson",
        AmmuInElquabrados[50] = "Ammunation In El Quebrados",
        LasVenturasPolice[50] = "Las Venturas Police Department",
        LosSantosPolice[50] = "Los Santos Police Department",
        SanFierroPolice[50] = "San Fierro Police Department",
        FourDragonCasino[50] = "The Four Dragon Casino",
        CaligulaCasino[50] = "Caligula's Casino";
   
    for(new j; j < sizeof(zones); j++) {
        if(IsPlayerInZone(playerid,j)) {
            memcpy(playerzone, zones[j][zone_name], 0, 108);
            break;
        }
        if(GetPlayerVirtualWorld(playerid) == 20) return LasVenturasPolice;
        if(GetPlayerVirtualWorld(playerid) == 21) return SanFierroPolice;
        if(GetPlayerVirtualWorld(playerid) == 22) return LosSantosPolice;
        if(GetPlayerVirtualWorld(playerid) == 11) return AmmuInMarket;
        if(GetPlayerVirtualWorld(playerid) == 12) return AmmuInComeALot;
        if(GetPlayerVirtualWorld(playerid) == 13) return AmmuInBoneCounty;
        if(GetPlayerVirtualWorld(playerid) == 14) return AmmuInFortCarson;
        if(GetPlayerVirtualWorld(playerid) == 15) return AmmuInElquabrados;
        if(GetPlayerVirtualWorld(playerid) == 23) return FourDragonCasino;
        if(GetPlayerVirtualWorld(playerid) == 24) return CaligulaCasino;
    }
    return playerzone;
}

Do you have any idea how I can implent this in the new stock?
pawn Code:
stock GetPlayer2DZone(playerid, zone[], len) //Credits to Cueball, Betamaster, Mabako, and Simon (for finetuning).
{
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        for(new i = 0; i != sizeof(gSAZones); i++ )
        {
                if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4])
                {
                    return format(zone, len, gSAZones[i][SAZONE_NAME], 0);

                }
        }
        return 0;
}
andrew2695 is offline   Reply With Quote
Old 02/08/2012, 10:02 AM   #2
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 1,608
Reputation: 220
Default Re: GetPlayer2DZone, Question custom zone names by VirtualWorlds

Try something like
pawn Code:
enum SAZONE {
    SAZONE_NAME[64],
    Float:SAZONE_AREA[4]
};

new gSAZones[1][SAZONE] = {
    {
        "Some name",
        { 0.0, 0.0, 0.0, 0.0 }
    }
};
some name is the name of your zone, and the coords are { xmin, ymin, xmax, ymax }
There is a something you have to change though;
pawn Code:
if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4])
//change to
if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][2] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][3])
I don't know why, but there was unused index 2
__________________
professional - engaged in a specified activity as one's main paid occupation rather than as an amateur.
Misiur is offline   Reply With Quote
Old 02/08/2012, 04:23 PM   #3
andrew2695
Big Clucker
 
Join Date: Oct 2010
Posts: 124
Reputation: 4
Default Re : GetPlayer2DZone, Question custom zone names by VirtualWorlds

Yea but I need to find a way to introduce "if(GetPlayerVirtualWorld(playerid) == 20) return MyDefinedLocationForVirtualWorld20;". So when I am in this interior the radar will say for example in Ammunation in market which has a defined virtual world. Any idea?
andrew2695 is offline   Reply With Quote
Old 02/08/2012, 04:38 PM   #4
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 1,608
Reputation: 220
Default Re: GetPlayer2DZone, Question custom zone names by VirtualWorlds

pawn Code:
stock GetPlayer2DZone(playerid, zone[], len)
{
    new AmmuInMarket[50] = "Ammunation In Market(LS)",
        AmmuInComeALot[50] = "Ammunation In Come-A-Lot",
        AmmuInBoneCounty[50] = "Ammunation In Bone County",
        AmmuInFortCarson[50] = "Ammunation In Fort Carson",
        AmmuInElquabrados[50] = "Ammunation In El Quebrados",
        LasVenturasPolice[50] = "Las Venturas Police Department",
        LosSantosPolice[50] = "Los Santos Police Department",
        SanFierroPolice[50] = "San Fierro Police Department",
        FourDragonCasino[50] = "The Four Dragon Casino",
        CaligulaCasino[50] = "Caligula's Casino",
        playerzone[50];
   
    for(new j; j < sizeof(zones); j++) {
        if(IsPlayerInZone(playerid,j)) {
            memcpy(playerzone, zones[j][zone_name], 0, 108);
            break;
        }
        switch (GetPlayerVirtualWorld(playerid)) {
            case 11: return AmmuInMarket;
            case 12: return AmmuInComeALot;
            case 13: return AmmuInBoneCounty;
            case 14: return AmmuInFortCarson;
            case 15: return AmmuInElquabrados;
            case 20: return LasVenturasPolice;
            case 21: return SanFierroPolice;
            case 22: return LosSantosPolice;
            case 23: return FourDragonCasino;
            case 24: return CaligulaCasino;
        }
    }
    if(playerzone[0] != '\0') return playerzone;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 0; i != sizeof(gSAZones); i++ )
    {
         if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3] && y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4])
        {
            return format(zone, len, gSAZones[i][SAZONE_NAME], 0);
        }
    }
    return 0;
}
I don't know if I understand your goal completely, but here I just merged them, so firstly it checks the virtual worlds, then the 2D Zones
__________________
professional - engaged in a specified activity as one's main paid occupation rather than as an amateur.
Misiur 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
Zone names Michael[NBK] Scripting Help 3 26/10/2011 02:20 PM
zone names on 0.3a help johnathon956 Help Archive 2 16/03/2010 05:32 PM
Zone names Sayaron Archive 4 28/12/2009 03:52 PM
Quick question about vehicles and VirtualWorlds Outbreak Help Archive 4 31/03/2009 11:31 PM


All times are GMT. The time now is 08:37 PM.


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