Zones shown in textdraw
#4

Hello.

You're going to need a timer if you want it to update automatically. You will also need to create a seperate text draw for every player, since each player can be in a different location.

Your script will need to work like this:
pawn Код:
new Text:zone[MAX_PLAYERS];
public OnGameModeInit(){
    for(new i; i<MAX_PLAYERS; i++){
        zone[i]=TextDrawCreate(487.000000, 4.000000, "San Andreas");
    }
    //This will create a text draw for every player.
    //I recommend replacing MAX_PLAYERS with the actual maximum number of players you can have in your server
    SetTimer("LocationTimer",2000,1);
    //This will create a timer that will update the zones of every player every 2 seconds
    return 1;
}
public OnPlayerConnect(playerid){
    TextDrawShowForPlayer(playerid, zone[playerid]);
    //Show the text draw for the player if not showing already
    return 1;
}
forward LocationTimer(){
    //If you have the foreach plugin, you should use that instead here
    for(new i; i<MAX_PLAYERS; i++){
        if(!IsPlayerConnected(i))continue;
        //skip players not connected.
        new zonename[MAX_ZONE_NAME];
        GetPlayer2DZone(playerid, zonename, MAX_ZONE_NAME);
        TextDrawSetString(zone[i],zonename);
        //Update the text draw with the player's zone
    }
}
public OnPlayerDisconnect(playerid,reason){
    TextDrawSetString(zone[playerid],"San Andreas");
    //Reset the text in the text draw when the player disconnects
    return 1;
}
Reply


Messages In This Thread
Zones shown in textdraw - by Ukko - 25.06.2012, 15:01
Re: Zones shown in textdraw - by Littlehelper - 25.06.2012, 15:04
Re: Zones shown in textdraw - by Ukko - 25.06.2012, 15:37
Re: Zones shown in textdraw - by Hawky133 - 25.06.2012, 16:57

Forum Jump:


Users browsing this thread: 1 Guest(s)