SA-MP Forums Archive
Safe place Help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Safe place Help! (/showthread.php?tid=577510)



Safe place Help! - KillerDVX - 12.06.2015

Hi Guys,

I made a Safe Mode place,

So i wan't to avoid the fights etc..

So i did this code :

PHP код:
if(gTeam[playerid] == TEAM_SURVIVANT && gTeam[issuerid] == TEAM_SURVIVANT) {
    if(
IsSafe[playerid] == 1) {
     
ApplyAnimation(playerid"DANCING""bd_clap"4.1111111);
     
SendClientMessage(playerid,COLOR_LIGHTBLUE"Vous ne pouvez blesser quelqu'un en Safe Mode");
     }
  } 
Under OnPlayerTakeDamage

But i didn't work, the players can shot they others.. :S

Help?


Re: Safe place Help! - [KHK]Khalid - 12.06.2015

It wouldn't work because OnPlayerTakeDamage is called after the damage is done, not before that. I may think of a more efficient way of doing this by using OnPlayerWeaponShot...

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    switch(hittype)
    {
        case BULLET_HIT_TYPE_PLAYER: // If what was hit by playerid is a PLAYER
        {
            if(gTeam[hitid] == TEAM_SURVIVANT && gTeam[playerid] == TEAM_SURVIVANT)
            {
                if(IsSafe[hitid] == 1)
                {
                    ApplyAnimation(hitid, "DANCING", "bd_clap", 4.1, 1, 1, 1, 1, 1, 1);
                    SendClientMessage(hitid, COLOR_LIGHTBLUE, "Vous ne pouvez blesser quelqu'un en Safe Mode");
                    // Here's the trick:
                    // we're going to return 0 if playerid is in Safe Mode
                    // which prevents the bullet and its damage
                    // like nothing happened in the first place
                    return 0; // prevent bullet and its damage
                }
            }
        }
    }
    return 1; // None of our checks were broken, so we should allow this bullet
}



Re : Safe place Help! - KillerDVX - 12.06.2015

It works, but i shows me that when i'm getting betten up.. xD


Re: Safe place Help! - [KHK]Khalid - 12.06.2015

I don't understand?


Re: Safe place Help! - Prokill911 - 12.06.2015

pawn Код:
if(gTeam[playerid] == TEAM_SURVIVANT && gTeam[issuerid] == TEAM_SURVIVANT) {
    if(IsSafe[playerid] == 1) {
     ApplyAnimation(playerid, "DANCING", "bd_clap", 4.1, 1, 1, 1, 1, 1, 1);
     TogglePlayerControllableEx(playerid, 0);
     SendClientMessage(playerid,COLOR_LIGHTBLUE, "Vous ne pouvez blesser quelqu'un en Safe Mode");
     }
}

That should fix your issue..
That will stop people taking DMG, But also it will stop them from moving.

Код:
#define FLOAT_INFINITY (Float:0x7F800000)
pawn Код:
if(gTeam[playerid] == TEAM_SURVIVANT && gTeam[issuerid] == TEAM_SURVIVANT) {
    if(IsSafe[playerid] == 1) {
     
     SetPlayerHealth(playerid, FLOAT_INFINITY);
     ApplyAnimation(playerid, "DANCING", "bd_clap", 4.1, 1, 1, 1, 1, 1, 1);
     SendClientMessage(playerid,COLOR_LIGHTBLUE, "Vous ne pouvez blesser quelqu'un en Safe Mode");
     } else {
         ClearAnimation(playerid);
         SetPlayerHealth(playerid, 100);
     }
}

That will stop them being damaged


Re : Safe place Help! - KillerDVX - 16.06.2015

Doesn't work..

Help?