OnPlayerClickPlayerTextdraw
#1

Having an issue where clicking on a player textdraw does nothing.

Assume that all these items are in their proper place.

They spawn in the correct place.
They show the correct icon.
They are click-able.
Clicking on them does nothing.

Код:
new PlayerText:TDArtifactIcon[MAX_PLAYERS][5];
        
		TDArtifactIcon[playerid][i] = CreatePlayerTextDraw(playerid, 302.333312 + (SPACING*(i-2)), 181.274566, "LD_NONE:ship3");
		PlayerTextDrawLetterSize(playerid, TDArtifactIcon[playerid][i], 0.000000, 0.000000);
		PlayerTextDrawTextSize(playerid, TDArtifactIcon[playerid][i], 32.000003, 31.940734);
		PlayerTextDrawAlignment(playerid, TDArtifactIcon[playerid][i], 1);
		PlayerTextDrawColor(playerid, TDArtifactIcon[playerid][i], -1);
		PlayerTextDrawSetShadow(playerid, TDArtifactIcon[playerid][i], 0);
		PlayerTextDrawSetOutline(playerid, TDArtifactIcon[playerid][i], 0);
		PlayerTextDrawFont(playerid, TDArtifactIcon[playerid][i], 4);
		PlayerTextDrawSetSelectable(playerid, TDArtifactIcon[playerid][i], true);

public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
	for(new i=0; i<5; i++)
	{
	    if(playertextid == PlayerText:TDArtifactIcon[playerid][i])
	    {
	        if(Artifact[playerid][i] == 0) return 1;
	        ArtifactEnabled[playerid][i] ^= 1;
	        HideArtifacts(playerid);
	        ShowArtifacts(playerid);
			SelectTextDraw(playerid, COLOR_GREY);
			return 1;
	    }
	}
    return 0;
}
RESOLUTION:
Quote:
Originally Posted by TheCman
Посмотреть сообщение
Both of you please check that you don't have other filterscripts or even your gamemode returning 1 in OnPlayerClickPlayerTextDraw. That would prevent the callback from being properly propagated to your current script.
Reply
#2

Код:
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
	for(new i=0; i<5; i++)
	{
	    if(playertextid == TDArtifactIcon[playerid][i])
	    {
	        if(Artifact[playerid][i] == 0) return 1;
	        ArtifactEnabled[playerid][i] ^= 1;
	        HideArtifacts(playerid);
	        ShowArtifacts(playerid);
			SelectTextDraw(playerid, COLOR_GREY);
			return 1;
	    }
	}
    return 0;
}
try this
Reply
#3

Quote:
Originally Posted by UFF
Посмотреть сообщение
try this
This was how it was scripted at first, and gives the same results.
Reply
#4

Debug

PHP код:
public OnPlayerClickPlayerTextDraw(playeridPlayerText:playertextid)
{
    
printf("playertextid = %d"playeridtextid);
    for(new 
i=0i<5i++)
    {
        
printf("TDArtifactIcon[%d][%d] = %d"playeridiTDArtifactIcon[playerid][i]);
        if(
playertextid == TDArtifactIcon[playerid][i])
        {
            
printf("TDArtifactIcon[playerid][%d] = playertextid"i);
            if(
Artifact[playerid][i] == 0) return 1;
            
ArtifactEnabled[playerid][i] ^= 1;
            
HideArtifacts(playerid);
            
ShowArtifacts(playerid);
            
SelectTextDraw(playeridCOLOR_GREY);
            return 
1;
        }
    }
    return 
0;

Reply
#5

Quote:
Originally Posted by Shinja
Посмотреть сообщение
Debug

PHP код:
public OnPlayerClickPlayerTextDraw(playeridPlayerText:playertextid)
{
    
printf("playertextid = %d"playeridtextid);
    for(new 
i=0i<5i++)
    {
        
printf("TDArtifactIcon[%d][%d] = %d"playeridiTDArtifactIcon[playerid][i]);
        if(
playertextid == TDArtifactIcon[playerid][i])
        {
            
printf("TDArtifactIcon[playerid][%d] = playertextid"i);
            if(
Artifact[playerid][i] == 0) return 1;
            
ArtifactEnabled[playerid][i] ^= 1;
            
HideArtifacts(playerid);
            
ShowArtifacts(playerid);
            
SelectTextDraw(playeridCOLOR_GREY);
            return 
1;
        }
    }
    return 
0;

Can't debug it that way, tag mismatch.
Reply
#6

Try this debug and tell me if there is any error/warning:
PHP код:
public OnPlayerClickPlayerTextDraw(playeridPlayerText:playertextid

    
printf("playertextid = %d"PlayerText:playeridtextid); 
    for(new 
i=0i<5i++) 
    { 
        
printf("TDArtifactIcon[%d][%d] = %d"playeridiTDArtifactIcon[playerid][i]); 
        if(
PlayerText:playertextid == PlayerText:TDArtifactIcon[playerid][i]) 
        { 
            
printf("TDArtifactIcon[playerid][%d] = playertextid"i); 
            if(
Artifact[playerid][i] == 0) return 1
            
ArtifactEnabled[playerid][i] ^= 1
            
HideArtifacts(playerid); 
            
ShowArtifacts(playerid); 
            
SelectTextDraw(playeridCOLOR_GREY); 
            return 
1
        } 
    } 
    return 
0

Reply
#7

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
Can't debug it that way, tag mismatch.
Which line?
Reply
#8

Problem is you are not updating the textsize accordingly.

Код:
PlayerTextDrawTextSize(playerid, TDArtifactIcon[playerid][i], 32.000003, 31.940734);
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Problem is you are not updating the textsize accordingly.

Код:
PlayerTextDrawTextSize(playerid, TDArtifactIcon[playerid][i], 32.000003, 31.940734);
Also incorrect. The resolution is that 2 filterscripts were returning 1 on the callback. All scripts need to return 0 otherwise this callback will not be called.

Quote:
Originally Posted by TheCman
Посмотреть сообщение
Both of you please check that you don't have other filterscripts or even your gamemode returning 1 in OnPlayerClickPlayerTextDraw. That would prevent the callback from being properly propagated to your current script.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)