updating location textdraw
#1

i'm using zones include.
i can't figure out how to make a timer to update my location textdraw so it tells me the right location always.

it looks like this: http://prntscr.com/mzjz9z even though im at airport in LS

this is my code:

Код:
	
        new string[100], zone[MAX_ZONE_NAME];
	GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
	format(string, sizeof(string), "%s", zone);


	LocationSystem[playerid][2] = CreatePlayerTextDraw(playerid, 71.200057, 319.207000, string);
	PlayerTextDrawLetterSize(playerid, LocationSystem[playerid][2], 0.134664, 0.803552);
	PlayerTextDrawAlignment(playerid, LocationSystem[playerid][2], 2);
	PlayerTextDrawColor(playerid, LocationSystem[playerid][2], -1);
	PlayerTextDrawSetShadow(playerid, LocationSystem[playerid][2], 0);
	PlayerTextDrawSetOutline(playerid, LocationSystem[playerid][2], 0);
	PlayerTextDrawBackgroundColor(playerid, LocationSystem[playerid][2], 255);
	PlayerTextDrawFont(playerid, LocationSystem[playerid][2], 2);
	PlayerTextDrawSetProportional(playerid, LocationSystem[playerid][2], 1);
	PlayerTextDrawSetShadow(playerid, LocationSystem[playerid][2], 0);
edit: its in a separated and i hooked OnPlayerConnect and Spawn
Reply
#2

Код:
use y_timers from YSI Library
#include <YSI\y_timers>

// nearby global vars
new locationString[40], zoneString[MAX_ZONE_NAME];

task oneSecondTimer[1000]() {
	locationString[0] = zoneString[0] = EOS;
	
	GetPlayer2DZone(playerid, zoneString, MAX_ZONE_NAME), format(locationString, 40, "%s", zoneString);
	foreach(new x : Player)
		PlayerTextDrawSetString(playerid, LocationSystem[playerid][2], locationString)
}

OnPlayerConnect(playerid) {
	LocationSystem[playerid][2] = CreatePlayerTextDraw(playerid, 71.200057, 319.207000, string);
	PlayerTextDrawLetterSize(playerid, LocationSystem[playerid][2], 0.134664, 0.803552);
	PlayerTextDrawAlignment(playerid, LocationSystem[playerid][2], 2);
	PlayerTextDrawColor(playerid, LocationSystem[playerid][2], -1);
	PlayerTextDrawSetShadow(playerid, LocationSystem[playerid][2], 0);
	PlayerTextDrawSetOutline(playerid, LocationSystem[playerid][2], 0);
	PlayerTextDrawBackgroundColor(playerid, LocationSystem[playerid][2], 255);
	PlayerTextDrawFont(playerid, LocationSystem[playerid][2], 2);
	PlayerTextDrawSetProportional(playerid, LocationSystem[playerid][2], 1);
	PlayerTextDrawSetShadow(playerid, LocationSystem[playerid][2], 0);
}
something like that
Reply
#3

hmm

error 017: undefined symbol "playerid"
error 017: undefined symbol "playerid"
error 021: symbol already defined: "@yH_OnPlayerConnect@004"
error 017: undefined symbol "string"
warning 209: function "@yH_OnPlayerConnect@004" should return a value

Код:
#include <a_samp>
#include <YSI\y_hooks>
#include <YSI\y_timers>
#include <zones>

new PlayerText:LocationSystem[MAX_PLAYERS][6];

new locationString[40], zoneString[MAX_ZONE_NAME];

task oneSecondTimer[1000]() {
	locationString[0] = zoneString[0] = EOS;
	
	GetPlayer2DZone(playerid, zoneString, MAX_ZONE_NAME), format(locationString, 40, "%s", zoneString);
	foreach(new x : Player)
		PlayerTextDrawSetString(playerid, LocationSystem[playerid][2], locationString)
}

hook OnPlayerConnect(playerid)
{
	LocationSystem[playerid][2] = CreatePlayerTextDraw(playerid, 71.200057, 319.207000, string);
	PlayerTextDrawLetterSize(playerid, LocationSystem[playerid][2], 0.134664, 0.803552);
	PlayerTextDrawAlignment(playerid, LocationSystem[playerid][2], 2);
	PlayerTextDrawColor(playerid, LocationSystem[playerid][2], -1);
	PlayerTextDrawSetShadow(playerid, LocationSystem[playerid][2], 0);
	PlayerTextDrawSetOutline(playerid, LocationSystem[playerid][2], 0);
	PlayerTextDrawBackgroundColor(playerid, LocationSystem[playerid][2], 255);
	PlayerTextDrawFont(playerid, LocationSystem[playerid][2], 2);
	PlayerTextDrawSetProportional(playerid, LocationSystem[playerid][2], 1);
	PlayerTextDrawSetShadow(playerid, LocationSystem[playerid][2], 0);
}
Reply
#4

ops, my fault
Код:
task oneSecondTimer[1000]() {
	locationString[0] = zoneString[0] = EOS;
	
	foreach(new x : Player) {
                GetPlayer2DZone(x, zoneString, MAX_ZONE_NAME), format(locationString, 40, "%s", zoneString);
		PlayerTextDrawSetString(x, LocationSystem[x][2], locationString)
        
        }
}
I gave u an example, try yourself now. If u will be used to copy+paste u won`t learn anything
Reply
#5

true that but im not familiar with y_timers yet

thanks, it works <3
Reply
#6

https://sampforum.blast.hk/showthread.php?tid=571044 this topic can help you to learn how to use y_timers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)