HELP with textdraws
#1

So I made textdraw
Quote:

new Text:intro;
public OnFilterScriptInit()
intro = TextDrawCreate(24.399976, 195.646636, "random");
TextDrawLetterSize(intro, 0.400000, 1.600000);
TextDrawTextSize(intro, 639.000000, 0.000000);
TextDrawAlignment(intro, 1);
TextDrawColor(intro, -1);
TextDrawUseBox(intro, 1);
TextDrawBoxColor(intro, 255);
TextDrawSetShadow(intro, 0);
TextDrawSetOutline(intro, 0);
TextDrawBackgroundColor(intro, 255);
TextDrawFont(intro, 1);
TextDrawSetProportional(intro, 1);
TextDrawSetShadow(intro, 0);
return 1;

and this
Quote:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
{
if (newkeys == 65536)
{
if(IsPlayerInRangeOfPoint(playerid,50,1279.2273,-1249.4648,13.5191))
{ new Text:intro;
TextDrawShowForPlayer(playerid,intro);
}
}
// This is if player Pressed LMB Then Textdraw will get hide
if (newkeys == KEY_FIRE)
{ new Text:intro;
TextDrawHideForPlayer(playerid,intro);
}
return 1;

but when i go ingame and press Y nothing shows but it says something on bottom left like show animation so i know key state is working but textdraw not appearing.
Reply
#2

Read this wiki page on how to check for a key.
Always initialize your textdraws, see this page for more information.
Reply
#3

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
Read this wiki page on how to check for a key.
Always initialize your textdraws, see this page for more information.
thanks but where do i put this new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};

And do i need to change anything from here >new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};

and i am 100% sure my keys are working.
Reply
#4

Global TextDraws:
Код:
new Text:gMyText = Text:INVALID_TEXT_DRAW; //This initializes the variable to an invalid TextDraw before creating the TextDraw.
The contents are the same for every player.
For example:
  • Global string is "www.sa-mp.com".
  • Shown to player 0.
  • Shown to player 1.
  • Hidden for player 2.
Per-player TextDraws:
Код:
new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; //This initializes every element of the array to an invalid TextDraw before creating every TextDraw.
The contents are different for every player.
For example:
  • There is no global string, but a personal string for every player.
  • Shown to player 0, string is "www.sa-mp.com".
  • Shown to player 1, string is "www.forum.sa-mp.com"
  • Hidden for player 2.
Reply
#5

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
Global TextDraws:
Код:
new Text:gMyText = Text:INVALID_TEXT_DRAW; //This initializes the variable to an invalid TextDraw before creating the TextDraw.
The contents are the same for every player.
For example:
  • Global string is "www.sa-mp.com".
  • Shown to player 0.
  • Shown to player 1.
  • Hidden for player 2.
Per-player TextDraws:
Код:
new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...}; //This initializes every element of the array to an invalid TextDraw before creating every TextDraw.
The contents are different for every player.
For example:
  • There is no global string, but a personal string for every player.
  • Shown to player 0, string is "www.sa-mp.com".
  • Shown to player 1, string is "www.forum.sa-mp.com"
  • Hidden for player 2.
thanks +1 rep but where would i put that, and is my script ok?
Reply
#6

Wait I'll answer everything individually.

Quote:
Originally Posted by kingZ7
Посмотреть сообщение
thanks but where do i put this new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
Top of your script is a good position.

Quote:
Originally Posted by kingZ7
Посмотреть сообщение
And do i need to change anything from here >new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
No, it makes sure there won't be any conflicts with other TextDraws.
You can change the name gMyPlayerText to anything you want of course.

Quote:
Originally Posted by kingZ7
Посмотреть сообщение
and i am 100% sure my keys are working.
When you are not pressing any other keys and really no other keys yes, that will work. As soon as you for example try crouching and pressing that key, it will not work anymore.
I still suggest reading that wiki page.

Quote:
Originally Posted by kingZ7
Посмотреть сообщение
is my script ok?
Try compiling what you have already.
Reply
#7

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
Wait I'll answer everything individually.


Top of your script is a good position.


No, it makes sure there won't be any conflicts with other TextDraws.
You can change the name gMyPlayerText to anything you want of course.


When you are not pressing any other keys and really no other keys yes, that will work. As soon as you for example try crouching and pressing that key, it will not work anymore.
I still suggest reading that wiki page.


Try compiling what you have already.
hey still not showing, i can guarantee you mean the keys are working.
Quote:

public OnFilterScriptInit()
{

new Text:intro;
intro = TextDrawCreate(24.399976, 195.646636, "random");
new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
TextDrawLetterSize(intro, 0.400000, 1.600000);
TextDrawTextSize(intro, 639.000000, 0.000000);
TextDrawAlignment(intro, 1);
TextDrawColor(intro, -1);
TextDrawUseBox(intro, 1);
TextDrawBoxColor(intro, 255);
TextDrawSetShadow(intro, 0);
TextDrawSetOutline(intro, 0);
TextDrawBackgroundColor(intro, 255);
TextDrawFont(intro, 1);
TextDrawSetProportional(intro, 1);
TextDrawSetShadow(intro, 0);
return 1;
}

Quote:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
{
if (newkeys == 65536)
{
if(IsPlayerInRangeOfPoint(playerid,50,1279.2273,-1249.4648,13.5191))
{ new Text:intro;
TextDrawShowForPlayer(playerid,intro);
}
}
// This is if player Pressed LMB Then Textdraw will get hide
if (newkeys == KEY_FIRE)
{ new Text:intro;
TextDrawHideForPlayer(playerid,intro);
}
return 1;
}
}

Reply
#8

Delete these lines.
Код:
//OnFilterScriptInit
new Text:intro;
//This means you can only use this TextDraw inside OnFilterScriptInit
//You also didn't initialize it
new PlayerText:gMyPlayerText[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
//You just copy-pasted this line... You're not even using this TextDraw anywhere

//OnPlayerKeyStateChange
new Text:intro;
//You're redefining this
new Text:intro;
//You're redefining this, for the second time
Keep these lines.
Код:
//OnFilterScriptInit
intro = TextDrawCreate(24.399976, 195.646636, "random");
TextDrawLetterSize(intro, 0.400000, 1.600000);
TextDrawTextSize(intro, 639.000000, 0.000000);
TextDrawAlignment(intro, 1);
TextDrawColor(intro, -1);
TextDrawUseBox(intro, 1);
TextDrawBoxColor(intro, 255);
TextDrawSetShadow(intro, 0);
TextDrawSetOutline(intro, 0);
TextDrawBackgroundColor(intro, 255);
TextDrawFont(intro, 1);
TextDrawSetProportional(intro, 1);
TextDrawSetShadow(intro, 0);

//OnPlayerKeyStateChange
TextDrawShowForPlayer(playerid,intro);
TextDrawHideForPlayer(playerid,intro);
Add this line.
Код:
//Top of script
new Text:intro = Text:INVALID_TEXT_DRAW;
Reply
#9

thanks so much its working i am sorry for copy and pasting but now i understand
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)