PDA

View Full Version : Pressing ESC - OnPlayerClickPlayerTextdraw


Natric
14/02/2014, 11:15 AM
Hello there,


I want that when player presses ESC if its a PLAYERTEXTDRAW it will be canceled, I tried several times and searched a lot and I really COULDN'T understand, can anyone fix up my code without telling me to read something!

Thanks in advance
The code:

public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
if(ShowingStats[playerid])
{
if(_:playertextid == Textdraw28 )
{
CancelSelectTextDraw(playerid);
HidePlayerStatusTextDraws(playerid);
return 1;
}
}
return 1;
}


public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if(ShowingStats[playerid])
{
if(_:clickedid == INVALID_TEXT_DRAW)
{
CancelSelectTextDraw(playerid);
HidePlayerStatusTextDraws(playerid);
}
return 1;
}
return 0;
}

Fix the codes! thanks buddies

CuervO
14/02/2014, 11:25 AM
Esc is not detected at OnPlayerClickPlayerTextDraw, it'll only work at OnPlayerClickTextdraw. Only the second one will work.

Natric
14/02/2014, 11:26 AM
Can you fix the code man

CuervO
14/02/2014, 11:31 AM
Can you fix the code man

What is exactly your problem? Which code bugs out? Provide more information.

Natric
14/02/2014, 11:33 AM
I put in my script both codes and got no warnings or errors, I logged ingame Showed the textdraw and when I press ESC the selection is canelled but the textdraws still appear..

Dignity
14/02/2014, 11:36 AM
Not sure as I rarely use textdraws, but I think you need to call the functions seperately. Try adding TextDrawDestroy(Text:text) under public OnPlayerClickTextDraw(playerid, Text:clickedid)

Natric
14/02/2014, 11:37 AM
It's a player textdraw not normal

Dignity
14/02/2014, 11:38 AM
TextDrawHideForPlayer(playerid, Text:text) ?

http://wiki.sa-mp.com/wiki/TextDrawHideForPlayer

CuervO
14/02/2014, 11:43 AM
Show us the HidePlayerStatusTextDraws() function.

Natric
14/02/2014, 11:46 AM
Mionee stop posting read about playertextdraws they're normal textdraws!!!

Alright CuervO:

stock HidePlayerStatusTextDraws(playerid)
{
PlayerTextDrawHide(playerid, Textdraw0);
PlayerTextDrawHide(playerid, Textdraw1);
PlayerTextDrawHide(playerid, Textdraw2);
PlayerTextDrawHide(playerid, Textdraw3);
PlayerTextDrawHide(playerid, Textdraw4);
PlayerTextDrawHide(playerid, Textdraw5);
PlayerTextDrawHide(playerid, Textdraw6);
PlayerTextDrawHide(playerid, Textdraw7);
PlayerTextDrawHide(playerid, Textdraw8);
PlayerTextDrawHide(playerid, Textdraw9);
PlayerTextDrawHide(playerid, Textdraw10);
PlayerTextDrawHide(playerid, Textdraw11);
PlayerTextDrawHide(playerid, Textdraw12);
PlayerTextDrawHide(playerid, Textdraw13);
PlayerTextDrawHide(playerid, Textdraw14);
PlayerTextDrawHide(playerid, Textdraw15);
PlayerTextDrawHide(playerid, Textdraw16);
PlayerTextDrawHide(playerid, Textdraw17);
PlayerTextDrawHide(playerid, Textdraw18);
PlayerTextDrawHide(playerid, Textdraw19);
PlayerTextDrawHide(playerid, Textdraw20);
PlayerTextDrawHide(playerid, Textdraw21);
PlayerTextDrawHide(playerid, Textdraw22);
PlayerTextDrawHide(playerid, Textdraw23);
PlayerTextDrawHide(playerid, Textdraw24);
PlayerTextDrawHide(playerid, Textdraw25);
PlayerTextDrawHide(playerid, Textdraw26);
PlayerTextDrawHide(playerid, Textdraw27);
PlayerTextDrawHide(playerid, Textdraw28);
}



In addition I want to say that it works when I click on the textdraw and shit in OnPlayerClickPlayerTextdraw it hides but once I show the textdraw again and press Escape it just cancels the textdraw selection without hiding the textdraw please fix the code or make a code I tried for two days and I can't overcome this problem!

Dignity
14/02/2014, 11:49 AM
I'm sorry, after your first post I thought you meant you were using player textdraws and not regular textdraws.

http://wiki.sa-mp.com/wiki/TextDrawDestroy

Is the line for regular textdraws though.

Natric
14/02/2014, 11:50 AM
I'm using player textdraws look at my last reply thanks anyway Mionee, I hope that CurevO will solve the problem or something

CuervO
14/02/2014, 11:51 AM
Try adding a debug under OnPlayerClickTextdraw, print something to see if the function is even called.

Maybe it's not called at all since there are no normal textdraws shown or selectable on your script.
This could maybe be solved by creating an invisible normal textdraw that is selectable, since this way OnPlayerClickTextdraw would be called.

Also, return 0 at OnPlayerClickPlayerTextdraw if no textdraws are found.

CH | FuDo
14/02/2014, 01:33 PM
Natric, didn't my response here helped you?

http://forum.sa-mp.com/showpost.php?p=2911586&postcount=15

CuervO
14/02/2014, 01:34 PM
Natric, didn't my response here helped you?

http://forum.sa-mp.com/showpost.php?p=2911586&postcount=15

playertextid will not be INVALID_PLAYER_TEXT_DRAW if cancelled.

http://wiki.sa-mp.com/wiki/OnPlayerClickTextDraw
http://wiki.sa-mp.com/wiki/OnPlayerClickPlayerTextDraw


EDIT: INVALID_PLAYER_TEXT_DRAW doesn't even exist. Tested it and it doesn't work.

CH | FuDo
15/02/2014, 09:29 AM
My apologies, try this:

PlayerText:INVALID_TEXT_DRAW