Godcar problem
#1

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;
}
Reply
#2

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.
Reply
#3

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;
}
Reply
#4

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

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


Forum Jump:


Users browsing this thread: