command unknown
#1

So i got this command where the admin can spawn any car of choice using the command /car and vip players can do the same by using the command /vcar but for some reason for vip it says that the command is unknown even tho the gamemode compiles perfectly.

Here are the codes for both commands :

Код:
// Lets the player choose a car to spawn (in a split list which shows only 10 cars at a time)
COMMAND:vcar(playerid, params[])
{
	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
	    // Check if the player's admin-level is at least 1
        if(PlayerInfo[playerid][pVIP] >= 2)
        {
	        // Make sure the player isn't inside a vehicle
			if(GetPlayerVehicleID(playerid) == 0)
	        CarList_Create(playerid); // Create a list of cars (only the first 10 cars) and show the dialog so the player can choose a car
	        return 1;
		}
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}

// Lets the player choose a car to spawn (in a split list which shows only 10 cars at a time)
COMMAND:car(playerid, params[])
{
	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
		// Check if the player's admin-level is at least 1
		if (APlayerData[playerid][PlayerLevel] >= 1)
		{
	        // Make sure the player isn't inside a vehicle
			if(GetPlayerVehicleID(playerid) == 0)
	        CarList_Create(playerid); // Create a list of cars (only the first 10 cars) and show the dialog so the player can choose a car
	        return 1;
		}
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}
Reply
#2

pawn Код:
return 0;
Change this with something like this :
pawn Код:
return SendClientMessage(playerid, -1, "Invalid level!");
Because return 0 = Unknown Command
Reply
#3

I made it this way but now when I use the command the dialog won't appear and it doesn't say that the command is unknown

Код:
// Lets the player choose a car to spawn (in a split list which shows only 10 cars at a time)
COMMAND:vcar(playerid, params[])
{
	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
	    // Check if the player's admin-level is at least 1
        if(PlayerInfo[playerid][pVIP] >= 2)
        {
	        // Make sure the player isn't inside a vehicle
			if(GetPlayerVehicleID(playerid) == 0)
	        CarList_Create(playerid); // Create a list of cars (only the first 10 cars) and show the dialog so the player can choose a car
		}
	}
	// Let the server know that this was a valid command
	return 1;
}
Reply
#4

Quote:
Originally Posted by JuanStone
Посмотреть сообщение
What is the problem, that command looks good, I do not understand, try it out with this sr.

Do you have defined in your script "CarList_Create" ?.

pawn Код:
COMMAND:vcar(playerid, params[])
{
    if(APlayerData[playerid][LoggedIn] == true)
    {
        if(PlayerInfo[playerid][pVIP] >= 2)
        {
            if(GetPlayerVehicleID(playerid) == 0) // ?
            {
                CarList_Create(playerid);
            }
        }
        else
        {
            SendClientMessage(playerid, -1, "You not are vip.");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "you not are loggedin.");
    }
    return true;
}
Yeah I do got CarList_Create defined here:

PHP код:
// This function creates a list of cars, starting from the FirstCar and automatically shows the dialog
CarList_Create(playerid)
{
    
// Setup local variables
    
new CounterCarList[500], DialogTitle[128];
    
// Only add 10 cars to the list, starting from the FirstCar
    
for (new APlayerData[playerid][DialogCarFirstCar]; sizeof(ACars); i++)
    {
        
// Increase a counter (which holds the number of cars that have been added to the list
        
Counter++;
        
// Check if the maximum hasn't been reached yet
        
if (Counter <= 10)
        {
            
// Add the carname to the list
            
if (strlen(CarList) == 0// If this is the start of the list (no cars have been added yet)
                
format(CarList500"%s"ACars[i][CarName]); // Add the name of the car at the start of the carlist
            
else
                
format(CarList500"%s%s%s"CarList"\n"ACars[i][CarName]); // Add the name of the next car to the list on the next line
        
}
        else 
// 10 cars have been added to the list (now Counter = 11)
        
{
            
// Add an empty line and "Next..." to the list to let the player know there are more cars to choose from
            
format(CarList500"%s%s%s"CarList"\n \n"TXT_DialogEntryNext);
            
// Also stop the For-loop
            
break;
        }
    }
    
// Construct the title for the dialog (to include a page number)
    
format(DialogTitle128TXT_DialogCarTitle, (APlayerData[playerid][DialogCarFirstCar] / 10) + 1);
    
// Ask which car the player wants to have by showing the dialog
    
ShowPlayerDialog(playeridDialogCarDIALOG_STYLE_LISTDialogTitleCarListTXT_DialogButtonSpawnTXT_DialogButtonCancel);
    return 
1;

I think the problem is that it won't recognize that I have VIP level even tho I do have VIP
Reply
#5

Use these
pawn Код:
COMMAND:vcar(playerid, params[])
{
    if(APlayerData[playerid][LoggedIn] != true)return SendClientMessage(playerid, -1, "{ff0000}You need to be logged in to use this command");
    if(PlayerInfo[playerid][pVIP] < 2)return SendClientMessage(playerid, -1, "{ff0000}You need to be a vip to use this command");
        if(IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, -1, "{ff0000}You need to be out of the vehicle to use this command.");
        CarList_Create(playerid);
        return 1;
}

COMMAND:car(playerid, params[])
{
    if (APlayerData[playerid][LoggedIn] != true)return SendClientMessage(playerid, -1, "{ff0000}You need to be logged in to use this command");
        if (APlayerData[playerid][PlayerLevel] < 1)return SendClientMessage(playerid, -1, "{ff0000}You need to be ADMIN in to use this command");
        if(IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, -1, "{ff0000}You need to be out of the vehicle to use this command.");
        CarList_Create(playerid);
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)