[SOLVED] Admin Vehicle Script -
Tigerbeast11 - 16.09.2009
Hi guys! Its me again with another noobish question! lol
Please reply to this!
I have made a tuned command script for admins! what it does is IT Makes the vehicle an admin vehicle so no-one else can get in! But i dont know how to the vehicle health to infinite.
Here is the script:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
printf("ID %d was at %d and changed to state %d",playerid,oldstate,newstate);
new currentState = GetPlayerState(playerid);
if (currentState == PLAYER_STATE_DRIVER)
{
//It's a driveby, take some money
if(IsPlayerInVehicle(playerid, tuned))
{
if(IsPlayerLAdmin(playerid))
{
SendClientMessage(playerid, 0xFFFF00FF,"Welcome to your admin car");
new vehicleid = GetPlayerVehicleID(playerid);
SetVehicleHealth(vehicleid,999999999.0);
}
else
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
It gives me no errors when i compile but in the script, the set vehicle health doesn't work, so the vehicle does blow up!
Please can u explain what I should do!
By the way, im rubbish at scripting as u might know from my recent posts so i would prefer it if u explained it detail
Thank you guys!
Re: Admin Vehicle Script -
Chaprnks - 16.09.2009
You could do a repeating timer, to reset it to 1000 every so seconds you put.
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
Re: Admin Vehicle Script -
Tigerbeast11 - 17.09.2009
Thnx , and I know what u mean! But, as i said, im not the best at scripting, so could u advance on the script above and tell me what to write and where!
Thank u
Re: Admin Vehicle Script -
Paladin - 17.09.2009
Quote:
Originally Posted by Chaprnks
|
That would waste memory.
Instead you could run a timer checking if the health is below 1000, if it is, then it resets the car's health to 1000 or 100, or whatever the default is.
Try this:
pawn Код:
// --- at the top of your script
new carvar;
new thetimer;
forward timer();
// ---
// --- Somewhere in your script
public timer()
{
new Float:chp;
GetVehicleHealth(tuned, chp);
if(chp < 9)
{
SetVehicleHealth(tuned, 1000);
return 1;
}
else
{
return 1;
}
}
// ---
// --- On your OnPlayerEnterVehicle
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == tuned)
{
if(IsPlayerAdmin(playerid))
{
thetimer = SetTimer("timer", 20000, true);
carvar = 1;
}
}
}
// ---
// --- On your OnPlayerExitVehicle
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == tuned)
{
if(IsPlayerAdmin(playerid))
{
if(carvar == 1)
{
carvar = 0;
KillTimer(thetimer);
}
}
}
}
// --- Enjoy
// By Micro
I still suggest you read through this:
SET TIMER
Re: Admin Vehicle Script -
Tigerbeast11 - 18.09.2009
Thnx man! This is what I wanted!
But, will it work for my tuned cmd! Ill check l8r and reply btw thnx again!
Quote:
I still suggest you read through this:
SET TIMER
|
I already read that but im new to scripting so i couldnt understand half of it lol!
Re: [SOLVED] Admin Vehicle Script -
hu11 - 07.10.2009
you put SetVehicleHealth(vehicleid, 9999999.0) needs to be SetVehicleHealth(vehicleid, -9999999.0)
Re: [SOLVED] Admin Vehicle Script -
dcgm19 - 21.10.2009
thanks you sooo much ive been looking for an admin only code
Re: [SOLVED] Admin Vehicle Script -
CAR - 22.10.2009
to set the vehicle health Max:
Код:
SetVehicleHealth(vehicleid, 100.0);
New in 0.3, (vehicleHealth 100 and no scratches or dents):
Код:
RepairVehicle(vehicleid);
Re: [SOLVED] Admin Vehicle Script -
Abernethy - 22.10.2009
Quote:
Originally Posted by CAR
to set the vehicle health Max:
Код:
SetVehicleHealth(vehicleid, 100.0);
New in 0.3, (vehicleHealth 100 and no scratches or dents):
Код:
RepairVehicle(vehicleid);
|
Max Vehicle health is 1000, not 100.
Re: [SOLVED] Admin Vehicle Script -
CAR - 22.10.2009
ok if it's true, do:
Код:
SetVehicleHealth(vehicleid, 1000.0)