SA-MP Forums Archive
Detecting preview model that is clicked by player. - 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: Detecting preview model that is clicked by player. (/showthread.php?tid=508900)



Detecting preview model that is clicked by player. - Cena44 - 24.04.2014

Hi there, I'm wondering if it's possible to detect what textdraw the player clicks. Say you make a single box that can be used to heal and suicide, with heal having the heart object and suicide having the skull object as preview models. Is it possible to detect which ones the player is clicking? So it would heal you if you click heart, and kill you if you click the skull.

I appreciate the help.


Re: Detecting preview model that is clicked by player. - arakuta - 24.04.2014

The clickedid in actually the textdraw id.

If you want two states, in the same textdraw just create a variable to store which state it is, and use this variable as a condition.


Re: Detecting preview model that is clicked by player. - Konstantinos - 24.04.2014

The preview model has been in a specific textdraw. Check if its ID is the same as the textdraw ID the player clicked and do your code.


Re: Detecting preview model that is clicked by player. - iBanner - 24.04.2014

I think it is possible. Just like when you picked a pickup with the object


Код:
new pickup_Health;
 
public OnGameModeInit()
{
    pickup_Health = CreatePickup(1240, 2, 0.0, 0.0, 9.0);
    return 1;
}
 
public OnPlayerPickUpPickup(playerid, pickupid)
{
    else if(pickupid == pickup_Health)
    {
        SetPlayerHealth(playerid, 100);
    }
    return 1;
}
But in your case use your textdraw variable.

Use this tutorial Clikable textdraw

Sample when you click a health textdraw
Код:
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    if(clickedid == health pickup)
    {
        SetPlayerHealth(playerid, 100);
    }



Re: Detecting preview model that is clicked by player. - Cena44 - 24.04.2014

So,
pawn Код:
modelindex == Heart/Skull object ID here
Right?


Re: Detecting preview model that is clicked by player. - arakuta - 24.04.2014

Whenever you set that the text is a skull store it in a variable, then check about it later. Should be a global variable.


Re: Detecting preview model that is clicked by player. - Cena44 - 24.04.2014

Alright, thanks guys. I really appreciate it.


Re: Detecting preview model that is clicked by player. - arakuta - 24.04.2014

Just do not have fear to ask or try