How to set health to all the sandkings?
#1

How to set all sandkings max heal 150... i mean when the sandking gets spawn he will start with 150% HP
Reply
#2

pawn Код:
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
    if(GetVehicleModel(vehicleid) == 495) // 411 is the Infernus model
    {
        SetVehicleHealth(vehicleid, 150);
        SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to FREE sandking!");
    }
    return 1;
}
Try this.
Reply
#3

Quote:
Originally Posted by Bingo
Посмотреть сообщение
pawn Код:
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
    if(GetVehicleModel(vehicleid) == 495) // 411 is the Infernus model
    {
        SetVehicleHealth(vehicleid, 150);
        SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to FREE sandking!");
    }
    return 1;
}
Try this.
Yeah but if they will need repair they will just get out and back in....
Reply
#4

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(GetVehicleModel(vehicleid) == 495) // 495 is the SK model
    {
       DestroyVehicle(vehicleid);
       SendClientMessage(playerid, 0xFF0000FF, "kwniwciwhwjnwni");
    {
     return 1;
}
But he cant park his vehicle and get in back so, Create spawn car cmd.
Reply
#5

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    if(GetVehicleModel(vehicleid) == 495) // Check if vehicle is Sandking
    {
        SetVehicleHealth(vehicleid, 150); // Set the vehicle health to 150
    }
    return 1;
}
Reply
#6

Wherever you want it to be set...

[pawn]for (new i = 0; i != MAX_PLAYERS; ++i)
{
if(GetVehicleModel(i) == 495) return SetVehicleHealth(i, 150);
}[pawn]

Untested.
Reply
#7

Quote:
Originally Posted by RunAways
Посмотреть сообщение
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    if(GetVehicleModel(vehicleid) == 495) // Check if vehicle is Sandking
    {
        SetVehicleHealth(vehicleid, 150); // Set the vehicle health to 150
    }
    return 1;
}
Nice... works but it's works after the car exploded... i mean only after he spawned... when Game Mode loaded it's not respawning the cars... just make them... how can i respawn all the cars when GameModeInit
Reply
#8

Quote:
Originally Posted by Lirbo
Посмотреть сообщение
Nice... works but it's works after the car exploded... i mean only after he spawned... when Game Mode loaded it's not respawning the cars... just make them... how can i respawn all the cars when GameModeInit
If I'm not wrong, if you're using CreateVehicle/AddStaticVehicle in OnGameModeInit, the vehicles will spawn normally. Just remove them while the server exits or restarts.

pawn Код:
// Putting this in OnGameModeExit or OnFilterScriptExit (if it's a filterscript)
for(new i = 0; i != MAX_VEHICLES; i++)
{
    // Destroy all the vehicles
    DestroyVehicle(i);
}

// Sets every Sandking health to 150.
// You have to put this to OnGameModeInit after the vehicle spawn codes
for(new i = 0; i != MAX_VEHICLES; i++)
{
    if(GetVehicleModel(i) == 495)
    {
        SetVehicleHealth(i, 150.0);
    }
}
Reply
#9

Hook the functions that create/add a vehicle. An example:
pawn Код:
stock HF_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
{
    if (modelid == 495) SetVehicleHealth(CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay), 150);
    else CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay);
    return 1;
}

#if defined _ALS_CreateVehicle
    #undef CreateVehicle
#else
    #define _ALS_CreateVehicle
#endif

#define CreateVehicle HF_CreateVehicle
Do the same for AddStaticVehicle and AddStaticVehicleEx too.

And when a vehicle respawns:
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    if (GetVehicleModel(vehicleid) == 495) SetVehicleHealth(vehicleid, 150);
    return 1;
}
Reply
#10

Quote:
Originally Posted by iZN
Посмотреть сообщение
If I'm not wrong, if you're using CreateVehicle/AddStaticVehicle in OnGameModeInit, the vehicles will spawn normally. Just remove them while the server exits or restarts.

pawn Код:
// Putting this in OnGameModeExit or OnFilterScriptExit (if it's a filterscript)
for(new i = 0; i != MAX_VEHICLES; i++)
{
    // Destroy all the vehicles
    DestroyVehicle(i);
}

// Sets every Sandking health to 150.
// You have to put this to OnGameModeInit after the vehicle spawn codes
for(new i = 0; i != MAX_VEHICLES; i++)
{
    if(GetVehicleModel(i) == 495)
    {
        SetVehicleHealth(i, 150.0);
    }
}
THANKS THANKS THANKS THANKS THANKS
BTW i had to add:
if(GetVehicleModel(vehicleid) == 495){SetVehicleHealth(vehicleid, 2125);}

It's made it 250 health after the car exploded... idk why but 2125 = 250 HP... O_O very weard
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)