GetPlayer2DZone, Question custom zone names by VirtualWorlds -
andrew2695 - 02.08.2012
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 Код:
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 Код:
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;
}
Re: GetPlayer2DZone, Question custom zone names by VirtualWorlds -
Misiur - 02.08.2012
Try something like
pawn Код:
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 Код:
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
Re : GetPlayer2DZone, Question custom zone names by VirtualWorlds -
andrew2695 - 02.08.2012
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?
Re: GetPlayer2DZone, Question custom zone names by VirtualWorlds -
Misiur - 02.08.2012
pawn Код:
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