/godcar, and /godcaroff help -
BigAl - 22.08.2011
pawn Code:
forward AutoR(playerid);
public AutoR(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vid = GetPlayerVehicleID(playerid);
RepairVehicle(vid);
}
return 1;
}
pawn Code:
new timer1;
COMMAND:godcar(playerid, cmdtext)
{
timer1 = SetTimer("AutoR", 1000, true);
return 1;
}
COMMAND:godcaroff(playerid, cmdtext)
{
KillTimer(timer1);
return 1;
}
How to fix this, this is really, really, really, bugged O.o Please help <3
Re: /godcar, and /godcaroff help -
[MWR]Blood - 22.08.2011
Try this code.
pawn Code:
new timer1[MAX_PLAYERS];
COMMAND:godcar(playerid, cmdtext)
{
timer1[playerid] = SetTimerEx("AutoR", 1000, true,"d",playerid);
return 1;
}
COMMAND:godcaroff(playerid, cmdtext)
{
KillTimer(timer1[playerid]);
return 1;
}
Re: /godcar, and /godcaroff help -
Improvement™ - 22.08.2011
Since MidoTrick's script code is messed up by 3 things, I made a re-make of his script.
Credit's goes to him.
pawn Code:
///Somewhere on top of your script
new bool:HasVehicleGodmode[MAX_PLAYERS];
//Under OnGameModeInit
SetTimer("Actualize", 2000, true);
//Under your Command Godmode (ON)
HasVehicleGodmode[playerid] = true;
//Under your Command Godmode (OFF)
HasVehicleGodmode[playerid] = false;
//Somewhere between all the Callbacks (public's)
forward AutoR(playerid);
public AutoR(playerid)
{
if(IsPlayerInAnyVehicle(playerid) && HasVehicleGodmode[playerid])
{
new vid = GetPlayerVehicleID(playerid);
RepairVehicle(vid);
}
return 1;
}
Re: /godcar, and /godcaroff help -
BigAl - 22.08.2011
Only one person on the server can use the godcar command now, why's this?
EDIT:Your version didn't work at all O.o
Re: /godcar, and /godcaroff help -
Dragony92 - 22.08.2011
pawn Code:
new GodMode[MAX_PLAYERS];
//Under OnGameModeInit
SetTimer("AutoR", 2000, true);
//Under your Command Godmode (ON)
GodMode[playerid] = 1;
//Under your Command Godmode (OFF)
GodMode[playerid] = 0;
forward AutoR(playerid);
public AutoR(playerid)
{
if(IsPlayerInAnyVehicle(playerid) && GodMode[playerid] == 1)
{
new vid = GetPlayerVehicleID(playerid);
RepairVehicle(vid);
}
return 1;
}
And also you can make public like this
pawn Code:
public AutoR(playerid)
{
if(IsPlayerInAnyVehicle(playerid) && GodMode[playerid] == 1)
{
new vid = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(vid, health);
if(health <999) // or lower....
{
RepairVehicle(vid);
}
}
}
Re: /godcar, and /godcaroff help -
Improvement™ - 22.08.2011
pawn Code:
//Somewhere on top of your script
new bool:VehicleGodmode[MAX_PLAYERS];
//Somewhere between all the Callbacks (public's)
COMMAND:godcar(playerid, cmdtext)
{
if(!VehicleGodmode) VehicleGodmode = true;
if(VehicleGodmode) VehicleGodmode = false;
}
//under "OnPlayerUpdate(playerid)" Callback (public)
if(VehicleGodmode) return RepairVehicle(GetPlayerVehicleID(playerid));
This should completly work.
Re: /godcar, and /godcaroff help -
=WoR=G4M3Ov3r - 22.08.2011
PHP Code:
CMD:godcar(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not an Admin");
{
new vehicleid = GetPlayerVehicleID(playerid);
SetVehicleHealth(vehicleid, 9999999999.0);
}
return 1;
}
PHP Code:
CMD:godcaroff(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not an Admin");
{
new vehicleid = GetPlayerVehicleID(playerid);
SetVehicleHealth(vehicleid, 1000.0);
}
return 1;
}
I Didn't know what did you really want, but these are working when you use /godcar and /godcaroff, And you don't need a useless timer.