Help with scripting something
#1

Hey all,
I tried to make a little script that if the player's hp <50 then auto /crack for a 15 seconds,
But I couldn't make that works.
Someone can help me with this thing?

Thanks
Reply
#2

pawn Код:
//under OnPlayerUpdate(playerid)
new Float:uhealth;
GetPlayerHealth(playerid, uhealth);
if(uhealth < 50.0) OnPlayerCommandText(playerid, "/crack");
Reply
#3

I've got something like this in my script:
Quote:

if(Vehhp <= 400)
{
if(IsPlayerInAnyVehicle(i))
{
TweakCooldown[i] = 3;
if(TweakCooldown[i] == 3)
{
TweakCooldownT[i]++;
CarRunning[VID] = 0;
new newstate;
newstate = GetPlayerState(i);
if(newstate == PLAYER_STATE_DRIVER)
{
TogglePlayerControllable(i,0);
if(TweakCooldownT[i] == 1)
{
SendClientMessage(i, COLOR_RED, " Your car gives out and stops running !");
SendClientMessage(i, COLOR_GREY, " /crack ) ");
TogglePlayerControllable(i,0);
}
if(TweakCooldownT[i] == 10)
{
SendClientMessage(i, COLOR_RED, " Your car gives out and stops running !");
SendClientMessage(i, COLOR_GREY, " /crack ) ");
}
if(TweakCooldownT[i] == 20)
{
SendClientMessage(i, COLOR_RED, " Your car gives out and stops running !");
SendClientMessage(i, COLOR_GREY, " /crack ) ");
TogglePlayerControllable(i,0);
}
}
}
}
}

Just adjust it like you want it.
Reply
#4

I will try both of your suggestions, But WHERE should I put these functions?
Reply
#5

Under "Public OnGameModeInit"
Reply
#6

Quote:
Originally Posted by ♣ ⓐⓢⓢ
pawn Код:
//under OnPlayerUpdate(playerid)
new Float:uhealth;
GetPlayerHealth(playerid, uhealth);
if(uhealth < 50.0) OnPlayerCommandText(playerid, "/crack");
Alright, Where shall i add this, and is this the only code that shall be added ?
Reply
#7

Quote:
Originally Posted by c0ke
Quote:
Originally Posted by ♣ ⓐⓢⓢ
pawn Код:
//under OnPlayerUpdate(playerid)
new Float:uhealth;
GetPlayerHealth(playerid, uhealth);
if(uhealth < 50.0) OnPlayerCommandText(playerid, "/crack");
Alright, Where shall i add this, and is this the only code that shall be added ?
Read the comment...

pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:uhealth;
    GetPlayerHealth(playerid, uhealth);
    if(uhealth < 50.0) OnPlayerCommandText(playerid, "/crack");
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)