SA-MP Forums Archive
Server unknown command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server unknown command (/showthread.php?tid=464337)



Server unknown command - TonyII - 16.09.2013

Hey, I got a vehicle lock command that works fine but when I get the message locked/unlocked I also get Server unknown command message, I tried replacing return 0; with return 1; but then the command didn't work like it should.
pawn Код:
if(strcmp(VehicleOwner[id], playername, true) == 0)
    {
    if(doors == 1)
    {
        doors = 0;
        VehicleLock[id] = 0;
        SendClientMessage(playerid, COLOR_GREEN, "Unlocked.");
    }
    else
    {
        doors = 1;
        VehicleLock[id] = 1;
        SendClientMessage(playerid, COLOR_RED, "Locked.");
    }
    SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
    SaveVehicle(id);
    return 0;
    }
    return 1;
}



Re: Server unknown command - xganyx - 16.09.2013

if you use OnPlayerCommandText

pawn Код:
if(strcmp(VehicleOwner[id], playername, true) == 0)
    {
    if(doors == 1)
    {
        doors = 0;
        VehicleLock[id] = 0;
        SendClientMessage(playerid, COLOR_GREEN, "Unlocked.");
    }
    else
    {
        doors = 1;
        VehicleLock[id] = 1;
        SendClientMessage(playerid, COLOR_RED, "Locked.");
    }
    SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
    SaveVehicle(id);
    }
    return 1;
}
return 0;
if zcmd

pawn Код:
if(strcmp(VehicleOwner[id], playername, true) == 0)
    {
    if(doors == 1)
    {
        doors = 0;
        VehicleLock[id] = 0;
        SendClientMessage(playerid, COLOR_GREEN, "Unlocked.");
    }
    else
    {
        doors = 1;
        VehicleLock[id] = 1;
        SendClientMessage(playerid, COLOR_RED, "Locked.");
    }
    SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
    SaveVehicle(id);
    }
    return 1;
}



Re: Server unknown command - TonyII - 16.09.2013

I use ZCMD, and I already told you that I tried removing return 0; under SaveVehicle(id); the cmd won't work as it should


Re: Server unknown command - Dragonsaurus - 16.09.2013

Mind showing us the whole command?


Re: Server unknown command - TonyII - 16.09.2013

pawn Код:
CMD:plock(playerid, params[])
{
    new id = GetClosestCar(playerid);
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    if(strcmp(VehicleOwner[id], playername, true) == 0)
    {
    if(doors == 1)
    {
        doors = 0;
        VehicleLock[id] = 0;
        SendClientMessage(playerid, COLOR_GREEN, "Unlocked.");
    }
    else
    {
        doors = 1;
        VehicleLock[id] = 1;
        SendClientMessage(playerid, COLOR_RED, "Locked.");
    }
    SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
    SaveVehicle(id);
    return 0;
    }
    return 1;
}



Re: Server unknown command - Dragonsaurus - 16.09.2013

pawn Код:
CMD:plock(playerid, params[])
{
    new id = GetClosestCar(playerid);
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    if(!strcmp(VehicleOwner[id], playername))
    {
        if(doors == 1)
        {
            doors = 0;
            VehicleLock[id] = 0;
            SendClientMessage(playerid, COLOR_GREEN, "Unlocked.");
        }
        else
        {
            doors = 1;
            VehicleLock[id] = 1;
            SendClientMessage(playerid, COLOR_RED, "Locked.");
        }
        SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
        SaveVehicle(id);
    }
    else SendClientMessage(playerid, -1, "You do not own the closest vehicle!");
    return 1;
}
Try this and see what happens, if it sends the message "You do not won the closest vehicle", the problem is at the VehicleOwner[id].


Re: Server unknown command - TonyII - 16.09.2013

If I don't use return 0; then anyone else can unlock the vehicle, https://sampwiki.blast.hk/wiki/Strcmp
So that is why I need return 0; right over there


Re: Server unknown command - Dragonsaurus - 16.09.2013

I believe you don't need it. Wiki does not mention that returning to 0 after comparing will cause such or similar bug.
It only says that if this function returns 0 (Which is same as using "!" in front of strcmp) the strings compare.
I think you misunderstood the function's return with the command's return.


Re: Server unknown command - TonyII - 16.09.2013

Alright, this brought me to a better point, but it's all reversed now so the owner can't unlock it but anyone else can, so thanks for the help I think I can handle it from here. For those who are interested in the codes.
pawn Код:
if(!strcmp(VehicleOwner[id], playername, true) == 0)
    {
    if(doors == 1)
    {
        doors = 0;
        VehicleLock[id] = 0;
        SendClientMessage(playerid, COLOR_GREEN, "Unlocked.");
    }
    else
    {
        doors = 1;
        VehicleLock[id] = 1;
        SendClientMessage(playerid, COLOR_RED, "Locked.");
    }
    SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
    SaveVehicle(id);
    }
    else SendClientMessage(playerid, -1, "You do not own the closest vehicle!");
    return 1;