SA-MP Forums Archive
Problem with OnPlayerWeaponShot - 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: Problem with OnPlayerWeaponShot (/showthread.php?tid=582656)



Problem with OnPlayerWeaponShot - Midzi - 22.07.2015

Hello, how can I protect object before the shoot?

Код:
new myobject = CreateObject(...

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(hittype == BULLET_HIT_TYPE_OBJECT)
    {
        if(hitid == myobject)
        {
            return 0; // Protect?
        }
    }
    
    return 1;
}
And next question. It's only work for CreateObject or CreateDynamicObject too?


Re: Problem with OnPlayerWeaponShot - JaydenJason - 22.07.2015

Protect? AFAIK doing this to an object that can be moved/destroyed (barrel/tied cop) this won't work, instead you can re-set object position or perhaps attach an object to that object and make it invisible.

Could you elaborate with what you mean with protect?


Re: Problem with OnPlayerWeaponShot - nezo2001 - 22.07.2015

I think he means to prevent the bullet from making damage to object


Re: Problem with OnPlayerWeaponShot - Midzi - 22.07.2015

@UP, exactly.

But.. I have done it by other way..

Код:
public OnPlayerShootDynamicObject(playerid, ...)
{
     if(objectid == myobject)
     {
          // recreate object
     }

     return 1;
}



Re: Problem with OnPlayerWeaponShot - Toxik - 22.07.2015

You shall use something like this
pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype != BULLET_HIT_TYPE_NONE ) // Bullet Crashing uses just this hittype
    {
        if( !( -1000.0 <= fX <= 1000.0 ) || !( -1000.0 <= fY <= 1000.0 ) || !( -1000.0 <= fZ <= 1000.0 ) ) // a valid offset, it's impossible that a offset bigger than 1000 is legit (also less than -1000.0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear). The object with biggest offset is having ~700-800 radius.
        {

            Ban(playerid);
            SendClientMessage(playerid,COLOR_YELLOW,"[ANTICHEAT]: You got Banned form server . post appeal on http://www.goofycrew.proboards.com ");
            SendClientMessage(playerid,COLOR_RED,"****[INFO]pres F8 and upload your pic on imgur.com****");
            return 0; // let's desynchronize that bullet, so players won't crash
        }
    }
    return 1;
}



Re: Problem with OnPlayerWeaponShot - Crystallize - 22.07.2015

Quote:
Originally Posted by Toxik
Посмотреть сообщение
You shall use something like this
pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype != BULLET_HIT_TYPE_NONE ) // Bullet Crashing uses just this hittype
    {
        if( !( -1000.0 <= fX <= 1000.0 ) || !( -1000.0 <= fY <= 1000.0 ) || !( -1000.0 <= fZ <= 1000.0 ) ) // a valid offset, it's impossible that a offset bigger than 1000 is legit (also less than -1000.0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear). The object with biggest offset is having ~700-800 radius.
        {

            Ban(playerid);
            SendClientMessage(playerid,COLOR_YELLOW,"[ANTICHEAT]: You got Banned form server . post appeal on http://www.goofycrew.proboards.com ");
            SendClientMessage(playerid,COLOR_RED,"****[INFO]pres F8 and upload your pic on imgur.com****");
            return 0; // let's desynchronize that bullet, so players won't crash
        }
    }
    return 1;
}
Not sure if retarded or what
I have no idea if you've read the topic properly , he wants to desynchronize the bullet that shoots the object not the unknown bullet hit type (A.K.A anticrasher)


Re: Problem with OnPlayerWeaponShot - Toxik - 22.07.2015

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
Not sure if retarded or what
I have no idea if you've read the topic properly , he wants to desynchronize the bullet that shoots the object not the unknown bullet hit type (A.K.A anticrasher)
woops my wrong i was sleeply let me think so i can help him