SA-MP Forums Archive
updating location textdraw - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: updating location textdraw (/showthread.php?tid=664990)



updating location textdraw - v4yne1 - 18.03.2019

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


Re: updating location textdraw - L0K3D - 18.03.2019

Код:
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


Re: updating location textdraw - v4yne1 - 18.03.2019

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);
}



Re: updating location textdraw - L0K3D - 18.03.2019

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


Re: updating location textdraw - v4yne1 - 18.03.2019

true that but im not familiar with y_timers yet

thanks, it works <3


Re: updating location textdraw - L0K3D - 19.03.2019

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