A little help please?
#1

Hey, i just need a little help with this bit of code.
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)//If they pressed the first button e.g. "Ok"
    {
    switch(dialogid)
        {
		case 1://Commands Dialog
    	    {
           	switch(listitem)//Which was chosen
        	{
        	    case 0:// /help
        	    {
				 	ShowPlayerDialog(playerid, 2, DIALOG_STYLE_MSGBOX, "Welcome to trollcity!", "Type in /cmds for a list of commands you can do here! That's about it for help.", "Ok", "Back");
        	    }
        	    case 1:// /kill
        	    {
				 	SetPlayerHealth(playerid, 0.0);
				 	SendClientMessage(playerid,COLOR_RED,"You've got some problems havent you! You suicidle thing!");
        	    }
        	    case 2:// race dialog
        	    {
        	    
        	    }
        	    case 3:// LV carpark
        	    {
        	    ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Avaliable Commands", "/car1 (open)\n/car2 (close)", "Ok", "Cancel");
        	    }
        	    }
        	}
     	case 2://Vip Commands Dialog
    	    {
           	switch(listitem)
        	{
        	    case 0:
        	    {
					GameTextForPlayer(playerid, "That's not a command", 50, 5);
        	    }
        	    case 1:
        	    {
        	        SetPlayerHealth(playerid, 0.0);
        	    }
        	    }
        	}
    	case 3://Race Dialog
    	    {
           	switch(listitem)
        	{
        	    case 0:
        	    {
	        		if (IsPlayerInAnyVehicle(playerid)) { //Checks if player is inside a vehicle
        			    new rand = random(sizeof(RandomSpawn));
        			    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
						SendClientMessage(playerid,COLOR_RED,"EY! Leave your vehicle next time. No vehicles in the spectator stands.");
						SendClientMessage(playerid,COLOR_RED,"It's now been teleported into a random place.");
        			} else {
            			SetPlayerPos(playerid,2978.1147,-2119.4758,7.2399); // teleports the player
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the spectating stands.");
        		}
        	    }
        	    case 1:
        	    {
        			if (IsPlayerInAnyVehicle(playerid)) { 
            			SetVehiclePos(GetPlayerVehicleID(playerid),2996.8394,-2067.2336,2.6237);
            			SendClientMessage(playerid,COLOR_YELLOW,"Your vehicle has been put in the first starting position.");
        			} else {
            			SetPlayerPos(playerid,3029.2441,-2060.5525,2.7871);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the racetrack! Pick a car and line up!");
        	    		}
        	    	}
      	    	case 2:
        	    {
	        		if (IsPlayerInAnyVehicle(playerid)) {
						SetVehiclePos(GetPlayerVehicleID(playerid),2996.8394,-2067.2336,2.6237);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the race track!");
        			} else {
            			SetPlayerPos(playerid,3029.2441,-2060.5525,2.7871);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the racetrack! Pick a car and line up!");
        				}
        	    	}
      	    	case 3:
        	    {
	        		if (IsPlayerInAnyVehicle(playerid)) {
						SetVehiclePos(GetPlayerVehicleID(playerid),2999.9817,-2067.3130,2.6237);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the race track!");
        			} else {
            			SetPlayerPos(playerid,3029.2441,-2060.5525,2.7871);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the racetrack! Pick a car and line up!");
        				}
        	    	}
      	    	case 4:
        	    {
	        		if (IsPlayerInAnyVehicle(playerid)) {
						SetVehiclePos(GetPlayerVehicleID(playerid),3002.9250,-2067.3926,2.6231);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the race track!");
        			} else {
            			SetPlayerPos(playerid,3029.2441,-2060.5525,2.7871);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the racetrack! Pick a car and line up!");
        				}
        	    	}
      	    	case 5:
        	    {
	        		if (IsPlayerInAnyVehicle(playerid)) {
						SetVehiclePos(GetPlayerVehicleID(playerid),3012.3232,-2067.3691,2.6249);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the race track!");
        			} else {
            			SetPlayerPos(playerid,3029.2441,-2060.5525,2.7871);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the racetrack! Pick a car and line up!");
        				}
        	    	}
      	    	case 6:
        	    {
	        		if (IsPlayerInAnyVehicle(playerid)) {
						SetVehiclePos(GetPlayerVehicleID(playerid),3015.1880,-2066.9187,2.6242);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the race track!");
        			} else {
            			SetPlayerPos(playerid,3029.2441,-2060.5525,2.7871);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the racetrack! Pick a car and line up!");
        				}
        	    	}
        	    case 7:
        	    {
	        		if (IsPlayerInAnyVehicle(playerid)) {
						SetVehiclePos(GetPlayerVehicleID(playerid),3018.5298,-2066.6333,2.6240);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the race track!");
        			} else {
            			SetPlayerPos(playerid,3029.2441,-2060.5525,2.7871);
            			SendClientMessage(playerid,COLOR_YELLOW,"Welcome to the racetrack! Pick a car and line up!");
       				}
    	    	}
     	case 4://LV Car park
    	    {
           	switch(listitem)
        	{
        	    case 0:
        	    {
					MoveObject(cargate, 2176.00878906,984.88964844,13.31524658, 2.000000);
        	    }
        	    case 1:
        	    {
        	        MoveObject(cargate, 2167.19897461,984.92883301,13.31524658, 2.000000);
					}
        	    }
        	    }
        	}
    	    }
		}
	}
return 1;
}
And I get this error.
Код:
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll - Copy.pwn(974) : error 040: duplicate "case" label (value 4)
I had a go at checking the brackets but i get about 4 errors instead.

Line 974 is :
Код:
case 4://LV Car park
So erm help?
Reply
#2

It doesn't work like that. You are checking
Код:
if(response)
without checking which dialog is currently open.
I'll post the code in a minute.

EDIT: It's a big code to edit.

Long thing short : First switch dialogids; In it: Check for a response
Код:
if(response)
under every dialog id; Inside that, switch listitems.
Reply
#3

Ignore this post
Reply
#4

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
    {
    if(response)
        {
		case 1://Commands Dialog
so anything like that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)