Error help
#1

I'm using this. and trying to make car shop.

Like this:

if player enter in checkpoint he gets main menu for example like:

1. Cars
2. Bikes

if he select cars by type '1' then another textdraw will be opened like

1. infernus
2. bullet

if he selects by type '2' bike then another textdraw will be opened like

1. FCR
2.PCJ


here's my code.

PHP код:
public OnPlayerText(playeridtext[])
{
    if(
carshopdentry{playerid}) // check if player in checkpoint or what
    
{
        switch(
carshopdentry{playerid})
        {
            case 
CARSHOPBOX// main menu like 1. cars 2. bikes
            
{
                switch(
strval(text))
                {
                    case 
1:  /// here if he selects 1 then it should show this to player
                    
{
                        
//Show your guns textdraw here.
                        
TextDrawShowForPlayer(playeridCARSHOPBOX);
                        
TextDrawShowForPlayer(playeridvehicleshop);
                    }
                    case 
2here if he selects 2 then it should show this to player
                    
{
                        
//Show your food textdraw here.
                        
TextDrawShowForPlayer(playeridCARSHOPBOX);
                        
TextDrawShowForPlayer(playeridbikeshop);
                    }
                }
            }
            case 
vehicleshop://If they selected the car i mean '1' = cars  textdraw, 
            
{
                switch(
strval(text))//Switch through the number they type in.
                
{
                    case 
1GivePlayerWeapon(playerid,22,50); // dnt mind this weapon i just checking it i will change it later and give vehicle to player 
                
}
            }
            case 
bikeshop:
            {
                switch(
strval(text))//Switch through the number they type in.
                
{
                    case 
1GivePlayerWeapon(playerid,31,50);//Give the player the weapon they typed the option for
                
}
            }
        }
        return 
0;
    } 
Reply
#2

try this the problem was that you used "{playerid}" instead of this "[playerid]"

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(carshopdentry[playerid]) // check if player in checkpoint or what
    {
        switch(carshopdentry[playerid])
        {
            case CARSHOPBOX: // main menu like 1. cars 2. bikes
            {
                switch(strval(text))
                {
                    case 1:  /// here if he selects 1 then it should show this to player
                    {
                        //Show your guns textdraw here.
                        TextDrawShowForPlayer(playerid, CARSHOPBOX);
                        TextDrawShowForPlayer(playerid, vehicleshop);
                    }
                    case 2: here if he selects 2 then it should show this to player
                    {
                        //Show your food textdraw here.
                        TextDrawShowForPlayer(playerid, CARSHOPBOX);
                        TextDrawShowForPlayer(playerid, bikeshop);
                    }
                }
            }
            case vehicleshop://If they selected the car i mean '1' = cars  textdraw,  
            {
                switch(strval(text))//Switch through the number they type in.
                {
                    case 1: GivePlayerWeapon(playerid,22,50); // dnt mind this weapon i just checking it i will change it later and give vehicle to player  
                }
            }
            case bikeshop:
            {
                switch(strval(text))//Switch through the number they type in.
                {
                    case 1: GivePlayerWeapon(playerid,31,50);//Give the player the weapon they typed the option for
                }
            }
        }
        return 0;
    }
Reply
#3

I did this what you said but got same 3 errors

PHP код:
(2336) : error 008must be a constant expressionassumed zero
(2354) : error 008must be a constant expressionassumed zero
(2361) : error 008must be a constant expressionassumed zero
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase


3 Errors

PHP код:
LINE 2336: case CARSHOPBOX:

Line 2354: case vehicleshop

line 2361
: case bikeshop
Reply
#4

Код:
case CARSHOPBOX;
Try and tell me.
Reply
#5

Nah, didn't work. Got many errors
Reply
#6

PHP код:
case CARSHOPBOX); 
Try this one I hope it works.
Reply
#7

@Kinglee Please learn what case is. Adding ; or ); will not help.
Reply
#8

Anyone help?
Reply
#9

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(carshopdentry{playerid}) // check if player in checkpoint or what
    {
        switch(carshopdentry{playerid})
        {
            case CARSHOPBOX: // main menu like 1. cars 2. bikes
            {
                switch(strval(text))
                {
                    case 0:  /// here if he selects 1 then it should show this to player
                    {
                        //Show your guns textdraw here.
                        TextDrawShowForPlayer(playerid, CARSHOPBOX);
                        TextDrawShowForPlayer(playerid, vehicleshop);
                    }
                    case 1: here if he selects 2 then it should show this to player
                    {
                        //Show your food textdraw here.
                        TextDrawShowForPlayer(playerid, CARSHOPBOX);
                        TextDrawShowForPlayer(playerid, bikeshop);
                    }
                }
            }
            case vehicleshop://If they selected the car i mean '1' = cars  textdraw,  
            {
                switch(strval(text))//Switch through the number they type in.
                {
                    case 0: GivePlayerWeapon(playerid,22,50); // dnt mind this weapon i just checking it i will change it later and give vehicle to player  
                }
            }
            case bikeshop:
            {
                switch(strval(text))//Switch through the number they type in.
                {
                    case 0: GivePlayerWeapon(playerid,31,50);//Give the player the weapon they typed the option for
                }
            }
        }
        return 0;
    }
the problem was that you used case 1 as the first case but the 1 case is actually 0.
Reply
#10

don't forget to change the {playerid} to the [playerid] .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)