Zones shown in textdraw
#1

Im trying to get zones to be shown in a textdraw located in the corner of the screen but i can't get pass the errors.

Код:
	TextDrawShowForPlayer(playerid, Rules);
	new string[200], zone[MAX_ZONE_NAME];
 	GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  	GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
 	Zone = TextDrawCreate(487.000000, 4.000000, "%s",zone);
Error: :
Код:
warning 202: number of arguments does not match definition
Which is line:
Код:
Zone = TextDrawCreate(487.000000, 4.000000, "%s",zone);
[/CODE]
I'm trying loads of stuff, include i'm using is: https://sampforum.blast.hk/showthread.php?tid=27598 ([INC] Zones By ~Cueball~ - V 2.0)

Appreciate help, new to scripting.
Reply
#2

pawn Код:
Zone = TextDrawCreate(487.000000, 4.000000, "  ");
// Then Later.
new string[128], zone[128];
format(string,sizeof(string),"%s",zone);
TextDrawSetString(Zone,string);
This is an example.
Reply
#3

Quote:
Originally Posted by Littlehelper[MDZ]
Посмотреть сообщение
pawn Код:
Zone = TextDrawCreate(487.000000, 4.000000, "  ");
// Then Later.
new string[128], zone[128];
format(string,sizeof(string),"%s",zone);
TextDrawSetString(Zone,string);
This is an example.
I placed the textdrawstuff at gamemodeinit, where should i place the rest of the code?
Doesnt show any zone when its all under gamemodeinit at least .


Код:
public OnGameModeInit()
	Zone = TextDrawCreate(487.000000, 4.000000, "  ");
Код:
public OnPlayerConnect(playerid)
{
       new string1[128], zone[128];
	GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
	format(string1,sizeof(string1),"%s",zone);
	TextDrawSetString(Zone,string1);
Now it's stuck at Blueberry Acres ?
I think i need something that keeps checking what zone you're in, but I don't know how .. or like refreshes the text idk
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)