OnPlayerKeyStateChange is buggy - 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: OnPlayerKeyStateChange is buggy (
/showthread.php?tid=532360)
OnPlayerKeyStateChange only works 1 time? -
yellow - 17.08.2014
Hey guys
Problem: KEY_CTRL_BACK only works 1 time.
Код:
if(newkeys & KEY_CTRL_BACK) //"H" Stats
{
printf("%d",h[playerid]);
if(h[playerid] == 1)
{
TextDrawHideForPlayer(playerid,Box);
TextDrawHideForPlayer(playerid,Credit);
TextDrawHideForPlayer(playerid,Line);
TextDrawHideForPlayer(playerid,Line2);
TextDrawHideForPlayer(playerid,Next);
TextDrawHideForPlayer(playerid,Back);
PlayerTextDrawHide(playerid,Status[playerid]);
PlayerTextDrawHide(playerid,Player[playerid]);
h[playerid] = 0;
}
else if(h[playerid] == 0){
/*
new currentpage[MAX_PLAYERS];
new Text:Box;
new Text:Credit;
new Text:Status;
new Text:Line;//
new Text:Player;//
new Text:Line2;//
new Text:Next;//
new Text:Back;//
*/
TextDrawShowForPlayer(playerid,Box);
TextDrawShowForPlayer(playerid,Credit);
PlayerTextDrawShow(playerid,Status[playerid]);
TextDrawShowForPlayer(playerid,Line);
PlayerTextDrawShow(playerid,Player[playerid]);
TextDrawShowForPlayer(playerid,Line2);
TextDrawShowForPlayer(playerid,Next);
TextDrawShowForPlayer(playerid,Back);
SelectTextDraw(playerid, 0x00FF00FF);
currentpage[playerid] = 1;
new playerload[64];
new p;
for(;p<MAX_PLAYERS;p++)
{
if(!IsPlayerConnected(p))continue;
GetPlayerName(p,name,sizeof(name));
format(playerload,sizeof(playerload),"%s\n%s ~g~%d",playerload,name,data[p][karma]);
}
PlayerTextDrawSetString(playerid,Player[playerid],playerload);
h[playerid] = 1;
}}
As you see, it should be like ths:
Player presses "H" 1 time-> Textdraws are shown
Player presses "H" a second time -> Textdraws should be hided.
I printed the var, where i check the state. (if he pressed 1 or. 2 times)
But I only get one result.
If I press "h" for a second time, nothing will happen. No print, no hide.
Do you see a mistake?
SOLVED!!
The Problem was "SelectTextDraw"