On and Off funkcion for this callback
#1

Hello, how can I do on and off funkcion for this callback?:
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
Reply
#2

Anyone?
Reply
#3

What do you mean on and off function? Also, why are you using GetPlayerVehicleID if the vehicle ID is already provided in the 'vehicleid' parameter?
Reply
#4

I need something like : On‌VehicleDamageStatusUpdate = 1;
Reply
#5

Quote:
Originally Posted by Tadas
Посмотреть сообщение
Hello, how can I do on and off funkcion for this callback?:
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
you could do it like this

pawn Код:
new bool:CB_Status;//global bool

//now some cmd to turn it on and off

YCMD:vehcb(playerid,params[],help)
{
    if(help) SendClientMessage(playerid,-1,"/vehcb Is used to turn the OnVehicleDamageStatusUpdate callback 'on' and 'off'");
    //if(... doing some admin check here would be good ...)
    if(!CB_Status) CB_Status = true;//turn it on when it was off
    else CB_Status = false;//turn it off when it was on
    return 1;
}

public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    if(!CB_Status) return 1;//stop here if <-- equals false
    RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
like this, the callback will be fullly executed when CB_Status equals true.
if it's not, it'll just stop at the first line, our control structure
Reply
#6

Quote:
Originally Posted by CutX
Посмотреть сообщение
you could do it like this

pawn Код:
new bool:CB_Status;//global bool

//now some cmd to turn it on and off

YCMD:vehcb(playerid,params[],help)
{
    if(help) SendClientMessage(playerid,-1,"/vehcb Is used to turn the OnVehicleDamageStatusUpdate callback 'on' and 'off'");
    //if(... doing some admin check here would be good ...)
    if(!CB_Status) CB_Status = true;//turn it on when it was off
    else CB_Status = false;//turn it off when it was on
    return 1;
}

public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    if(!CB_Status) return 1;//stop here if <-- equals false
    RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
like this, the callback will be fullly executed when CB_Status equals true.
if it's not, it'll just stop at the first line, our control structure
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)