Convert
#3

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
It's possibile to convert this stock:

pawn Код:
stock GetZoneName(Float: x, Float: y, Float: z)
{
    new zone[28];
    for(new i = 0; i < sizeof(SAZones); i++)
    {
        if(x >= SAZones[i][SAZONE_AREA][0] && x <= SAZones[i][SAZONE_AREA][3] && y >= SAZones[i][SAZONE_AREA][1] && y <= SAZones[i][SAZONE_AREA][4] && z >= SAZones[i][SAZONE_AREA][2] && z <= SAZones[i][SAZONE_AREA][5])
        {
            strcat(zone, SAZones[i][SAZONE_NAME]);
            return zone;
        }
    }

    strcat(zone, "Unknown");
    return zone;
}
To return the zone name of the player? Currently it works only with x, y and z floats, but i need it for the player pos.

I could add GetPlayerPos then use that stocks but is stupid...is there a way to convert it?
Код:
GetPlayerZone(playerid)
{
new Float:x, Float:y, Float:z, zone[28];
GetPlayerPos(playerid, x, y, z);

strcat(zone, GetZoneName(x, y, z));

return zone;
}
Although functions that return arrays are usually bad. I'd make both functions pass the zone name by reference, since that doesn't require the extra step of declaring a temporary zone array. When passing arrays by reference the target array does not have to match the source's size which is more convenient as well.

Or simply copy the code of GetZoneName and replace the arguments x, y, z with playerid and get the player's position.
Reply


Messages In This Thread
Convert - by KinderClans - 02.10.2018, 16:37
Re: Convert - by Alexis17 - 02.10.2018, 16:48
Re: Convert - by NaS - 02.10.2018, 16:53
Re: Convert - by KinderClans - 02.10.2018, 17:01
Re: Convert - by KinderClans - 05.10.2018, 08:51

Forum Jump:


Users browsing this thread: 1 Guest(s)