textdraws.pwn
#1

how can i seperate textdraws to another .pwn file and use them as an include ?
i read a tutorial about modular programming but I dont understand it.

this is how i made 'textdraws.pwn' file:

Код:
#include <a_samp>

new PlayerText:TDEditor_PTD[MAX_PLAYERS][4];

public OnPlayerConnect(playerid)
{
	TDEditor_PTD[playerid][0] = CreatePlayerTextDraw(playerid, 21.233411, 432.966857, "NAME");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][0], 0.149332, 0.869924);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][0], 2);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][0], -1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][0], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][0], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][0], 255);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][0], 2);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][0], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][0], 0);

	TDEditor_PTD[playerid][1] = CreatePlayerTextDraw(playerid, 4.666687, 431.837371, "box");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][1], 0.000000, 1.200001);
	PlayerTextDrawTextSize(playerid, TDEditor_PTD[playerid][1], 130.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][1], -1);
	PlayerTextDrawUseBox(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawBoxColor(playerid, TDEditor_PTD[playerid][1], 100);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][1], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][1], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][1], 255);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][1], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][1], 0);

	TDEditor_PTD[playerid][2] = CreatePlayerTextDraw(playerid, 6.333343, 433.910980, "box");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][2], 0.000000, 0.766664);
	PlayerTextDrawTextSize(playerid, TDEditor_PTD[playerid][2], 38.000000, 0.000000);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][2], -1);
	PlayerTextDrawUseBox(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawBoxColor(playerid, TDEditor_PTD[playerid][2], -1005750197);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][2], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][2], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][2], -1005750197);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][2], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][2], 0);

	TDEditor_PTD[playerid][3] = CreatePlayerTextDraw(playerid, 82.566764, 433.066955, "Player_Name");
	PlayerTextDrawLetterSize(playerid, TDEditor_PTD[playerid][3], 0.149332, 0.869924);
	PlayerTextDrawAlignment(playerid, TDEditor_PTD[playerid][3], 2);
	PlayerTextDrawColor(playerid, TDEditor_PTD[playerid][3], -1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][3], 0);
	PlayerTextDrawSetOutline(playerid, TDEditor_PTD[playerid][3], 0);
	PlayerTextDrawBackgroundColor(playerid, TDEditor_PTD[playerid][3], 255);
	PlayerTextDrawFont(playerid, TDEditor_PTD[playerid][3], 2);
	PlayerTextDrawSetProportional(playerid, TDEditor_PTD[playerid][3], 1);
	PlayerTextDrawSetShadow(playerid, TDEditor_PTD[playerid][3], 0);

	PlayerTextDrawShow(playerid, PlayerText:TDEditor_PTD[playerid][0]);
	PlayerTextDrawShow(playerid, PlayerText:TDEditor_PTD[playerid][1]);
	PlayerTextDrawShow(playerid, PlayerText:TDEditor_PTD[playerid][2]);
	PlayerTextDrawShow(playerid, PlayerText:TDEditor_PTD[playerid][3]);
	return 1;
}
i used:
Код:
#include "textdraws.pwn"
in my gamemode (textdraws.pwn is in gamemodes folder)

and i get this error when I compile my gamemode:

error 021: symbol already defined: "SSCANF_OnPlayerConnect"

thanks in advance
Reply
#2

Instead, include a_samp only in the main file, which is your gamemode, then compile the gamemode, not the filterscript. Use includes for that
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
You need to hook the callback in includes.
hmmm, can you give me an example? i dont understand, it seems hard

https://sampforum.blast.hk/showthread.php?tid=392061

btw im honored by your reply

or can i use textdraws in a filterscript? i want to seperate them from my main gamemode just so the code looks more clean
Reply
#4

Use y_hooks https://sampforum.blast.hk/showthread.php?tid=570884

pawn Код:
#include <YSI/y_hooks>

hook OnPlayerConnect(playerid)
{
    // whatever
    return 1;
}
Reply
#5

thanks a lot.

btw using '/' drops an error. it has to be '\' in #include <YSI\y_hooks>
Reply
#6

Glad you figured it out by yourself, silly mistake.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)