SA-MP Forums Archive
Textdraw help - 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: Textdraw help (/showthread.php?tid=576162)



Textdraw help - STONEGOLD - 01.06.2015

Hi, I made a checkpoint and whenever players go to this checkpoint so they get a textdraw

like
1. 9mm
2. ak47
3. m4

But when i type "1" it doesn't let me buy 9mm. So, I want if player go to this checkpoint and get textdraw and when they type "1" they should get number one thing for example if i type "1" so i should get 9mm.

Idk how to do this. anyone help me?

Here's my code.

PHP код:
if(checkpointid == PizzaRob)
    {
    
SendClientMessage(playeridGRIS"Type /robstore to this store.");
    
TextDrawShowForPlayer(playeridpizzabox);
    
TextDrawShowForPlayer(playeridpizza);

As you can see when player enters "pizzarob" checkpoint so they get pizaabox textdraw but they type "1" or "2" they get nothing. Anyone help me?


Re: Textdraw help - Banana_Ghost - 01.06.2015

PHP код:
new bool:pizzarobtdentry[MAX_PLAYERS char];//Creating a variable to store if the player is in the checkpoint or not.
//Your code
if(checkpointid == PizzaRob)
{
    
SendClientMessage(playeridGRIS"Type /robstore to this store.");
    
TextDrawShowForPlayer(playeridpizzabox);
    
TextDrawShowForPlayer(playeridpizza);
    
pizzarobtdentry{playerid} = true;//Setting the variable to true, because they are in the checkpoint.
}
    
public 
OnPlayerText(playerid,text[]){
    if(
pizzarobtdentry{playerid} == true)//If they are in the checkpoint, they can use the chat to respond to it.
    
{
        switch(
strval(text))//Switch through the number they type in.
        
{
            case 
1GivePlayerWeapon(playerid,22,50);//Give the player the weapon they typed the option for
            
case 2GivePlayerWeapon(playerid,30,50);
            case 
3GivePlayerWeapon(playerid,31,50);
        }
        
TextDrawHideForPlayer(playerid,pizzabox);//hide the textdraws
        
TextDrawHideForPlayer(playerid,pizza);
        
pizzarobtdentry{playerid} = false;//Set the variable to false
        
return 0;//return 0 so that the number they type will not display in the chat.
    
}
    return 
1;

Remember to reset the variable upon death, spawn, connect, etc to prevent players from using it without entering the checkpoint, after leaving the checkpoint, or other instances.


Re: Textdraw help - STONEGOLD - 01.06.2015

Aight thank you so much But What if i want like this.

Like
1. Guns
2.Food

when you press 1. GUNS it shows you another textdraw

like
1.9mm
2.ak47

and when you press 2. FOOD

1.Ice cream
2.Burger

I want to see this code. Would be your thankful =)


Re: Textdraw help - Banana_Ghost - 01.06.2015

PHP код:
new textdrawid[MAX_PLAYERS char];//Creating a variable to store if the player is in the checkpoint or not.
#define INVALID_TEXTDRAWMENUOPTION 0
#define PIZZAROBMAIN_TEXTDRAW 1
#define GUNS_TEXTDRAW 2
#define FOOD_TEXTDRAW 3
//Your code
if(checkpointid == PizzaRob)
{
    
SendClientMessage(playeridGRIS"Type /robstore to this store.");
    
TextDrawShowForPlayer(playeridpizzabox);
    
TextDrawShowForPlayer(playeridpizza);
    
pizzarobtdentry{playerid} = PIZZAROBMAIN_TEXTDRAW;//Setting the variable to the main textdraw, because they are in the checkpoint.
}
    
public 
OnPlayerText(playerid,text[]){
    if(
textdrawid{playerid} > INVALID_TEXTDRAWMENUOPTION)
    {
        switch(
textdrawid{playerid})
        {
            case 
PIZZAROBMAIN_TEXTDRAW:
            {
                switch(
strval(text))
                {
                    case 
1:
                    {
                        
//Show your guns textdraw here.
                        
textdrawid{playerid} = GUNS_TEXTDRAW;
                    }
                    case 
2:
                    {
                        
//Show your food textdraw here.
                        
textdrawid{playerid} = FOOD_TEXTDRAW;
                    }
                }
            }
            case 
GUNS_TEXTDRAW://If they selected the guns textdraw, check their response.
            
{
                switch(
strval(text))//Switch through the number they type in.
                
{
                    case 
1GivePlayerWeapon(playerid,22,50);//Give the player the weapon they typed the option for
                    
case 2GivePlayerWeapon(playerid,30,50);
                    case 
3GivePlayerWeapon(playerid,31,50);
                }
            }
            case 
FOOD_TEXTDRAW:
            {
                
//Add your option to perform when a player selects a food item, it is in the same manner as above.
            
}
        }
        return 
0;
    }
    return 
1;
}
//Whereever you hide the textdraws, add this:
pizzarobtdentry{playerid} = INVALID_TEXTDRAWMENUOPTION;//Set the variable to false 



Re: Textdraw help - STONEGOLD - 01.06.2015

Whenever i buy one thing then i have to go out from checkpoint and get in back so i can buy 2.

I don't want player get out from checkpoint and comes back. I want player stays in checkpoint and can buy all things together. but in this code if i buy a thing then i have to get out from checkpoint and comes again in checkpoint and type 2. Anyone help me?


Re: Textdraw help - Banana_Ghost - 02.06.2015

just add an option to the textdraws like "Previous Page", and under OnPlayerText under that menu id, add a new option to go back to the previous page.