SA-MP Forums Archive
Command problem.. - 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: Command problem.. (/showthread.php?tid=477478)



Command problem.. - Lajko1 - 24.11.2013

I will post 2 command because problem might be in command above /gascan

pawn Код:
if(strcmp(cmdtext, "/refuel", true) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be in vehicle to use this command.");
        if(IsRefuelling[playerid] == true) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are already refueling!");
        if(IsPlayerInRangeOfGasStations(playerid))
        {
            if(Carinfo[vehicleid][F] >= 99) SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}Your fuel tank is full!");
            {
                KillTimer(GasTimer[playerid]); // It will kill timer to avoid any bugs
                if(Carinfo[vehicleid][F] > 90 && Carinfo[vehicleid][F] < 99) GasPrice = 50;
                if(Carinfo[vehicleid][F] > 80 && Carinfo[vehicleid][F] < 90) GasPrice = 100;
                if(Carinfo[vehicleid][F] > 70 && Carinfo[vehicleid][F] < 80) GasPrice = 150;
                if(Carinfo[vehicleid][F] > 60 && Carinfo[vehicleid][F] < 70) GasPrice = 200;
                if(Carinfo[vehicleid][F] > 50 && Carinfo[vehicleid][F] < 60) GasPrice = 250;
                if(Carinfo[vehicleid][F] > 40 && Carinfo[vehicleid][F] < 50) GasPrice = 300;
                if(Carinfo[vehicleid][F] > 30 && Carinfo[vehicleid][F] < 40) GasPrice = 350;
                if(Carinfo[vehicleid][F] > 20 && Carinfo[vehicleid][F] < 30) GasPrice = 400;
                if(Carinfo[vehicleid][F] > 10 && Carinfo[vehicleid][F] < 20) GasPrice = 450;
                if(Carinfo[vehicleid][F] < 10) GasPrice = 500;
                if(GetPlayerMoney(playerid) < GasPrice) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You don't have enough money.");
                IsRefuelling[playerid] = true;
                SetCameraBehindPlayer(playerid);
                TogglePlayerControllable(playerid, 0);
                GameTextForPlayer(playerid, "Refuelling...", 1000, 5);
                SetTimerEx("RefuelVehicle", 5000, 0, "d", playerid);
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are not near any gas pump.");
            return 1;
        }
    }
   
    if(strcmp(cmdtext, "/gascan", true) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be in vehicle to use this command.");
        if(IsPlayerInRangeOfGasStations(playerid))
        {
            //
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are not near any gas pump.");
            return 1;
        }
    }
    return 1;
    }
    return 0; // error line
}
error (error line is marked in command /gascan - "return 0;")
pawn Код:
error 010: invalid function or declaration



Re: Command problem.. - Konstantinos - 24.11.2013

You have an extra closed bracket and return.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/refuel", true) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be in vehicle to use this command.");
        if(IsRefuelling[playerid] == true) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are already refueling!");
        if(IsPlayerInRangeOfGasStations(playerid))
        {
            if(Carinfo[vehicleid][F] >= 99) SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}Your fuel tank is full!");
            {
                KillTimer(GasTimer[playerid]); // It will kill timer to avoid any bugs
                if(Carinfo[vehicleid][F] > 90 && Carinfo[vehicleid][F] < 99) GasPrice = 50;
                if(Carinfo[vehicleid][F] > 80 && Carinfo[vehicleid][F] < 90) GasPrice = 100;
                if(Carinfo[vehicleid][F] > 70 && Carinfo[vehicleid][F] < 80) GasPrice = 150;
                if(Carinfo[vehicleid][F] > 60 && Carinfo[vehicleid][F] < 70) GasPrice = 200;
                if(Carinfo[vehicleid][F] > 50 && Carinfo[vehicleid][F] < 60) GasPrice = 250;
                if(Carinfo[vehicleid][F] > 40 && Carinfo[vehicleid][F] < 50) GasPrice = 300;
                if(Carinfo[vehicleid][F] > 30 && Carinfo[vehicleid][F] < 40) GasPrice = 350;
                if(Carinfo[vehicleid][F] > 20 && Carinfo[vehicleid][F] < 30) GasPrice = 400;
                if(Carinfo[vehicleid][F] > 10 && Carinfo[vehicleid][F] < 20) GasPrice = 450;
                if(Carinfo[vehicleid][F] < 10) GasPrice = 500;
                if(GetPlayerMoney(playerid) < GasPrice) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You don't have enough money.");
                IsRefuelling[playerid] = true;
                SetCameraBehindPlayer(playerid);
                TogglePlayerControllable(playerid, 0);
                GameTextForPlayer(playerid, "Refuelling...", 1000, 5);
                SetTimerEx("RefuelVehicle", 5000, 0, "d", playerid);
            }
        }
        else SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are not near any gas pump.");
        return 1;
    }
   
    if(strcmp(cmdtext, "/gascan", true) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You need to be in vehicle to use this command.");
        if(IsPlayerInRangeOfGasStations(playerid))
        {
            // code..
        }
        else SendClientMessage(playerid, COLOR_RED,"{FF6A22}INFO: {FFFFFF}You are not near any gas pump.");
        return 1;
    }

    // rest of commands..

    return 0;
}



Re: Command problem.. - Sublime - 24.11.2013

-delete-


Re: Command problem.. - Lajko1 - 24.11.2013

Oh thank you guys