format() causing SERVER: Unknown command
#1

Okay, this is the /lock command of my gamemode. For some reason when you are outside of the vehicle and try doing /lock it locks/unlocks it fine, but returns Unknown command. If I take the format() line out it fixes the problem, but I don't see any problem with the format line. Does anyone have any ideas? I'm really stumped...

pawn Код:
CMD:lock(playerid, params[]) {

    new engine, lights, alarm, doors, hood, trunk, objective;
    new invehicleid = GetPlayerVehicleID(playerid);
    new model = GetVehicleModel(invehicleid);


// THESE LINES WORK FINE...
    if(IsPlayerInAnyVehicle(playerid)) {
   
        GetVehicleParamsEx(invehicleid, engine, lights, alarm, doors, hood, trunk, objective);
       
        if(doors == 0) {
       
            LockVehicle(invehicleid);
           
            format(msgstring, sizeof(msgstring), "presses a button on the door and locks the %s.", VehicleNames[model-400]);
            AutoMe(playerid, msgstring);
           
        } else if(doors == 1) {
       
            UnlockVehicle(invehicleid);
           
            format(msgstring, sizeof(msgstring), "presses a button on the door and unlocks the %s.", VehicleNames[model-400]);
            AutoMe(playerid, msgstring);
           
        }
       
    } else {

// THESE format() LINES CAUSE THE COMMAND TO ERROR OUT AND RETURN SERVER: UNKNOWN COMMAND

        new cv, vehd;

        cv = GetClosestCar(playerid);
        vehd = GetDistanceToCar(playerid, cv);

        GetVehicleParamsEx(cv, engine, lights, alarm, doors, hood, trunk, objective);

        if(vehd <= 10.00) {

            if(doors == 0) {

                if(PlayerHasCarKey(playerid, cv)) {

                    LockVehicle(cv);

                    if(PlayerData[playerid][pSex] == 0) {
                   
                        format(msgstring, sizeof(msgstring), "takes his keys and locks the %s.", VehicleNames[model-400]);
                        AutoMe(playerid, msgstring);
                       
                    } else if(PlayerData[playerid][pSex] == 1) {
                   
                        format(msgstring, sizeof(msgstring), "takes her keys and locks the %s.", VehicleNames[model-400]);
                        AutoMe(playerid, msgstring);
                       
                    }
                   
                }

            } else if(doors == 1) {
           
                if(PlayerHasCarKey(playerid, cv)) {

                    UnlockVehicle(cv);
                   
                    if(PlayerData[playerid][pSex] == 0) {

                        format(msgstring, sizeof(msgstring), "takes his keys and unlocks the %s.", VehicleNames[model-400]);
                        AutoMe(playerid, msgstring);

                    } else if(PlayerData[playerid][pSex] == 1) {

                        format(msgstring, sizeof(msgstring), "takes her keys and unlocks the %s.", VehicleNames[model-400]);
                        AutoMe(playerid, msgstring);

                    }
                   
                }

            }

        }

    }

    return 1;
   
}
Reply
#2

try
forward OnPlayerCommandPerformed(playerid, cmdtext[], success);

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!success) SendClientMessage(playerid, COLOR_RED, "");
return 1;
}
and add TO THE COMMAND
OnPlayerCommandPerformed(playerid, cmdtext[], success);
NOTE: NOT TESTED>
Reply
#3

I use zcmd.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)