Interior name
#1

pawn Код:
new ZoneName[MAX_PLAYERS][128];

enum IntZoneInfo
{
    IntName[27],
    Float:IntMinX,
    Float:IntMinY,
    Float:IntMaxX,
    Float:IntMaxY
}

new Float:IntZone[][IntZoneInfo] =
{
    { "Cluckin Bell",   362.6255,   -12.18620381.4123,   -6.106100},
    { "Ammunation",     283.9484,   -112.9781298.6097,   -102.7812}
};

stock GetPlayerInteriorName(playerid)
{
    new Float:posX, Float:posY, Float:posZ;
    GetPlayerPos(playerid, posX, posY, posZ);
    if(posZ > 500.0)
    {
        for(new i=0; i < sizeof(IntZone); i++)
        {
            if(IsPlayerInArea(playerid, IntZone[playerid][IntMinX], IntZone[playerid][IntMinY], IntZone[playerid][IntMaxX], IntZone[playerid][IntMaxY]))
            {
                format(ZoneName[playerid], 128, IntZone[playerid][IntName]);
            }
        }
    }
    else
    {
        ZoneName[playerid] = "Unknown";
    }
    return ZoneName[playerid];
}

stock IsPlayerInArea(playerid, Float:minX, Float:minY, Float:maxX, Float:maxY)
{
    new Float:posX, Float:posY, Float:posZ;
    GetPlayerPos(playerid, posX, posY, posZ);
    if(posX >= minX && posX <= maxX && posY >= minY && posY <= maxY) return 1;
    return 0;
}
This returns to wrong name
Reply
#2

You can't use strings inside of enumerations.
Reply
#3

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
You can't use strings inside of enumerations.
No you can.

@Unknown123 what do you mean by wrong name?
Reply
#4

Like if im in the Ammunation, then it sais Cluckin Bell, and somethimes it output blank

i use this to test
pawn Код:
CMD:int(playerid,params[])
{
    new string[128];
    format(string,sizeof(string),"Interior name: %s", GetPlayerInteriorName(playerid));
    SendClientMessage(playerid,-1,string);
    return 1;
}
Reply
#5

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
No you can.

@Unknown123 what do you mean by wrong name?
Not if you're using it like that.
Reply
#6

Quote:
Originally Posted by Backwardsman97
Посмотреть сообщение
Not if you're using it like that.
Then how shoud i use it?
Reply
#7

Create a seperate array to deal with the names.
Reply
#8

pawn Код:
OnPlayerChangeInterior(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid,20,XCenter,YCenter,ZCenter) return format(ZoneName[playerid],128,"Cluckin Bell");
Much better?
Reply
#9

pawn Код:
stock GetPlayerInteriorName(playerid)
{
    new Float:posX, Float:posY, Float:posZ;
    GetPlayerPos(playerid, posX, posY, posZ);
    if(posZ > 500.0)
    {
        for(new i = 0; i < sizeof(IntZone); i++)
        {
            if(IsPlayerInArea(playerid, IntZone[i][IntMinX], IntZone[i][IntMinY], IntZone[i][IntMaxX], IntZone[i][IntMaxY]))
            {
                format(ZoneName[playerid], 128, IntZone[i][IntName]);
            }
        }
    }
    else
    {
        ZoneName[playerid] = "Unknown";
    }
    return ZoneName[playerid];
}
Reply
#10

Ty man!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)