Hmm im guessing something wrong with brackets ?
#1

Код:
if(strcmp(cmd, "/car", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /car [name");
				SendClientMessage(playerid, COLOR_GRAD2, "Available division names: lights,hood,trunk");
				return 1;
			}
			if(strcmp(params, "lights", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
			{
				new vehicleid = GetPlayerVehicleID(playerid);
				if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
				SetVehicleLights(vehicleid, playerid);
			}
			else if(strcmp(params, "hood", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
			{
				if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
				{
					new vehicleid = GetPlayerVehicleID(playerid);
					if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510 || IsAPlane(vehicleid) || IsABike(vehicleid))
					{
						return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
					}
					SetVehicleHood(vehicleid, playerid);
			}
			else if(!IsPlayerInAnyVehicle(playerid))
			{
				new closestcar = GetClosestCar(playerid);
				if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
				{
					if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510 || IsAPlane(closestcar) || IsABike(closestcar))
					{
						return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
					}
					SetVehicleHood(closestcar, playerid);
				}
			}
			else if(strcmp(params, "trunk", true) == 0)
  			{
				if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
				{
					new vehicleid = GetPlayerVehicleID(playerid);
					if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
					{
						return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
					}
					SetVehicleTrunk(vehicleid, playerid);
				}
			else if(!IsPlayerInAnyVehicle(playerid))
			{
				new closestcar = GetClosestCar(playerid);
				if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
				{
					if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510)
					{
						return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
					}
					SetVehicleTrunk(closestcar, playerid);
				}
			}
		}
		return 1;
	}
Guessing something is wrong with the brackets , crashes my pawno.exe when i try to compile it. Compiles fine when i remove this code ?
Reply
#2

If your having some trouble with brackets, here's my recommendation.

Count the amount of opening brackets as opposed to the closing ones. There should be a set equal amount.

You have 16 opening brackets and 14 closed. If you had more closed than opening, you would received an error saying "unmatched bracket", but since Pawno crashes, you now know that you have more of { and less of }.

To Solve your problem:

pawn Код:
if(strcmp(cmd, "/car", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /car [name");
                SendClientMessage(playerid, COLOR_GRAD2, "Available division names: lights,hood,trunk");
                return 1;
            }
            if(strcmp(params, "lights", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                new vehicleid = GetPlayerVehicleID(playerid);
                if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
                SetVehicleLights(vehicleid, playerid);
            }
            else if(strcmp(params, "hood", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
                {
                    new vehicleid = GetPlayerVehicleID(playerid);
                    if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510 || IsAPlane(vehicleid) || IsABike(vehicleid))
                    {
                        return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
                    }
                    SetVehicleHood(vehicleid, playerid);
            }
            else if(!IsPlayerInAnyVehicle(playerid))
            {
                new closestcar = GetClosestCar(playerid);
                if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
                {
                    if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510 || IsAPlane(closestcar) || IsABike(closestcar))
                    {
                        return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                    }
                    SetVehicleHood(closestcar, playerid);
                }
            }
            else if(strcmp(params, "trunk", true) == 0)
            {
                if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
                {
                    new vehicleid = GetPlayerVehicleID(playerid);
                    if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
                    {
                        return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
                    }
                    SetVehicleTrunk(vehicleid, playerid);
                }
            else if(!IsPlayerInAnyVehicle(playerid))
            {
                new closestcar = GetClosestCar(playerid);
                if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
                {
                    if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510)
                    {
                        return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                    }
                    SetVehicleTrunk(closestcar, playerid);
                }
            }
        }
    }
}
return 1;
}
There is now a fixed set of amount of brackets, 16-16.

In the future, might I recommend using the [PAWN] tags instead of the [CODE]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)