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



Godcar problem - martoivanov - 15.07.2013

Every time when i use the command /godcar it shows me that it is enabled. how can I fix it?
Code:
pawn Код:
dcmd_godcar(playerid,params[]) {
    #pragma unused params
    new Godcar[MAX_PLAYERS];
    new vehicleid = GetPlayerVehicleID(playerid);
    if(inDM[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"sthsthsth!(/leavedm)");
    if(Godcar[playerid]==0) {
        Godcar[playerid]=1;
        SetVehicleHealth(vehicleid, 999999999);
        SendClientMessage(playerid,COLOR_LIGHT_GREEN,"GODCAR: ON");
    } else
    if(Godcar[playerid]==1) {
        Godcar[playerid]=0;
        SetVehicleHealth(vehicleid, 100);
        SendClientMessage(playerid,COLOR_RED,"GODCAR: OFF");
    }
    return 1;
}



AW: Godcar problem - NaS - 15.07.2013

Make the variable global, so put this:

Код:
new Godcar[MAX_PLAYERS];
above all public functions.

In OnPlayerConnect(playerid) you should add:

Код:
Godcar[playerid] = 0;
Furthermore the 3rd if() isn't needed because you use else there.

Also, you should set the vehicle's health to 1000.0, where you have "100.0".
The vehicle would start burning if setting it to 100.


Re: Godcar problem - Anak - 15.07.2013

pawn Код:
dcmd_godcar(playerid,params[]) {
    #pragma unused params
    new Godcar[MAX_PLAYERS];
    new vehicleid = GetPlayerVehicleID(playerid);
    if(inDM[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"sthsthsth!(/leavedm)");
    if(Godcar[playerid] == 0) {
        Godcar[playerid] =1;
        SetVehicleHealth(vehicleid, 999999999);
        SendClientMessage(playerid,COLOR_LIGHT_GREEN,"GODCAR: ON");
    } else
    {
        Godcar[playerid]=0;
        SetVehicleHealth(vehicleid, 100);
        SendClientMessage(playerid,COLOR_RED,"GODCAR: OFF");
    }
    return 1;
}



AW: Godcar problem - NaS - 15.07.2013

Yea, almost. You forgot to move the "Godcar" variable.


Re: Godcar problem - martoivanov - 15.07.2013

Thank you all! It works! +1rep!!!