I need to understand clickable textdraws
#8

oh that
like this --
pawn Код:
new bool:IsViewingMenu[MAX_PLAYERS];//on top
new current[MAX_PLAYERS] = -1;//specifies the current text draw on which player pointer is

IsViewingMenu[playerid] = true;//when u show menu to the player using TextDrawShowForplayer

public OnPlayerUpdate(playerid)
{

if(IsViewingMenu[playerid])
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);//for getting player keys up and down you can read about this in wiki
if(ud == KEY_DOWN && cuurent[playerid] != 4)//to do nothing when the pointer is at last text draw,i.e., 4
{

current[playerid]++;
switch(current[playerid])
{
case 0 : PlayerTextDrawColor(playerid, Textdraw0[playerid], 0xFF0000FF); //setting current text draw color to red
case 1 :
{
PlayerTextDrawColor(playerid, Textdraw0[playerid], -1);//setting old text draw color to back to white
PlayerTextDrawColor(playerid, Textdraw1[playerid], 0xFF0000FF);
}
case 2 :
{
PlayerTextDrawColor(playerid, Textdraw1[playerid], -1);//setting old text draw color to back to white
PlayerTextDrawColor(playerid, Textdraw2[playerid], 0xFF0000FF);
}
//like this for others too

}//end of switch

else if(ud == KEY_UP && (cuurent[playerid] != -1 || current[playerid] != 0))//to do nothing when pointer is nowhere or at first textdraw ,i.e, 0
{
current[playerid]--;
switch(current[playerid])
{
case 0 :
{
PlayerTextDrawColor(playerid, Textdraw0[playerid], 0xFF0000FF);//setting current pointer color to red
PlayerTextDrawColor(playerid, Textdraw1[playerid], -1);//setting textdraw color where pointer "was" back to white
}
case 1 :
{
PlayerTextDrawColor(playerid, Textdraw1[playerid], 0xFF0000FF);//setting current pointer color to red
PlayerTextDrawColor(playerid, Textdraw2[playerid], -1);//setting textdraw color where pointer "was" back to white
}
//like this for others
}//end of switch

}

}
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsViewingMenu[playerid])
{
if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE) && current[playerid] != -1)//change to key whatever u want
{
switch(current[playerid])
{
case 0://player is on menu item 1 do something
case 1://player is on menu item 2
}
}
}
return 1;
}

//this all when u hide menu or player disconnects
current[playerid] = -1;
IsViewingMenu[playerid] = false;
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)