OnPlayerWeaponShot problem.
#1

As the title says.

I created a C4 script, and it can be detonated in 2 ways.

1) /detonatec4
2) Shooting at the box

But if i shoot at the box, and something goes wrong, it bugs the player ( Basically, no commands work etc. )

Code which i have at OnPlayerWeaponShot*
pawn Код:
//My code here ( if( hittype == BULLET_HIT_TYPE_OBJECT ) )
else if( hitid == 3052 || hitid == C4OBject )
    {
        foreach(Player, i)
        {
            if(IsPlayerInRangeOfPoint(i, 15, C4Pos[0], C4Pos[1], C4Pos[2]))
            {
                if(!SKProtection{ i })
                {
                    OnPlayerDeath(i, playerid, 39);
                    SpawnPlayer(i);
                GameTextForPlayer(i, "~r~You got C4'd!", 3500, 3);
                }
            }
            else if(IsPlayerInRangeOfPoint(i, 25, C4Pos[0], C4Pos[1], C4Pos[2]))
            {
                if(!SKProtection{ i })
        {
                SetPlayerHealth(i, 36);
            SendClientMessage(i, COLOR_RED, "* You got damaged from the C4 blast!");
        }
            }
            if(PlayerUsedBomb{ i })
            {
                DestroyObject(C4Object[i]);
                PlayerUsedBomb{ i } = false;
                Delete3DTextLabel(C4[i]);
            }
        }
        CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 2, 100);
    CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 3, 100);
    CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 4, 100);
    //Delete3DTextLabel(C4[playerid]);
}
Or is something wrong at the way i create the C4 stuff?
Reply
#2

If you don't mind can you show your /detonatec4 code?
Reply
#3

Quote:
Originally Posted by [vTc]Patroool
Посмотреть сообщение
If you don't mind can you show your /detonatec4 code?
pawn Код:
CMD:detonatec4(playerid, params[]) {
    if(Medic{ playerid } || Assault{ playerid } || Engineer{ playerid }) return SendClientMessage(playerid, COLOR_RED, "* Only Snipers(Recons) and Gunners(Supporters) can use the C4!");
    if(PlayerUsedBomb{ playerid })
    {
        GetObjectPos(C4Object[playerid], C4Pos[0], C4Pos[1], C4Pos[2]);
        foreach(Player, i)
        {
            if(IsPlayerInRangeOfPoint(i, 15, C4Pos[0], C4Pos[1], C4Pos[2]))
            {
                if(!SKProtection{ i })
                {
                    OnPlayerDeath(i, playerid, 39);
                    SpawnPlayer(i);
                    GameTextForPlayer(i, "~r~You got C4'd!", 3500, 3);
                }
            }
            else if(IsPlayerInRangeOfPoint(i, 25, C4Pos[0], C4Pos[1], C4Pos[2]))
            {
                if(!SKProtection{ i })
                {
                    SetPlayerHealth(i, 48);
                    SendClientMessage(i, COLOR_RED, "* You got damaged from the C4 blast!");
                }
            }

        }
        CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 2, 100);
        CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 3, 100);
        CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 4, 100);
       
        DestroyObject(C4Object[playerid]);
        PlayerUsedBomb{ playerid } = false;
       
        Delete3DTextLabel(C4[playerid]);
    }
    else SendClientMessage(playerid, COLOR_RED, "* You haven't planted a C4, plant one by using /createc4 or /plantc4!");
    return 1;
}
Reply
#4

I cant see return 1; under OnPlayerWeaponShot.

Its a callback brother, Must return a value.
Reply
#5

Quote:
Originally Posted by [vTc]Patroool
Посмотреть сообщение
I cant see return 1; under OnPlayerWeaponShot.

Its a callback brother, Must return a value.
There is "return 1"
at the end of all of that.

pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype == BULLET_HIT_TYPE_OBJECT )
    {
        if( hitid == Minigun || hitid == 2985 )
        {
            MinigunHealth--;
            new string[112], kname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, kname, sizeof(kname));
            format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~r~MINIGUN DAMAGED~n~HP: ~r~%d~h~~h~/~r~100", MinigunHealth);
            GameTextForPlayer(playerid, string, 1000, 3);
            if(MinigunHealth == 35)
            {
                foreach(Player, i)
                {
                    new stringg[112];
                    format(stringg, sizeof(stringg), "* %s[%d] has damaged the minigun to %d/100 health!", kname, playerid, MinigunHealth);
                    SendClientMessage(i, COLOR_RED, stringg);
                    SendClientMessage(i, COLOR_RED, "* The Minigun has enabled its Advanced Self-Defense mode!");
                   
                    MinigunDamage = 20;
                    MinigunRange = 55;
                }
            }
            else if(MinigunHealth == 1)
            {
                format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~r~MINIGUN DESTROYED\nHP: ~w~%d~r~/~r~100", MinigunHealth);
                GameTextForPlayer(playerid, string, 1500, 3);
                foreach(Player, i)
                {
                    new name[MAX_PLAYER_NAME];
                    if(SpawnedBy{ i })
                    {
                        GetPlayerName(i, name, sizeof(name));
                        new stringgg[112];
                        format(stringgg, sizeof(stringgg), "* %s[%d] destroyed [%d]%s's minigun!", name, playerid, i, name);
                        SendClientMessageToAll(COLOR_SWAG, stringgg);
                        SetPlayerHealth(playerid, 99);
                        GivePlayerScore(playerid, 3);
                        GivePlayerCash(playerid, 15000);
                        SendClientMessage(playerid, COLOR_SWAG, "* You've received 3 score and 15'000$!");
                           
                        CanControlMG{ i } = false;
                        SpawnedBy{ i } = false;
                           
                    }
                }
                Minigun = DestroyObject(Minigun);
                Miniguns = 0;
                foreach(Player, i)
                {
                    KillTimer(MTimer[i]);
                }
            }
        }
        else if( hitid == 3052 || hitid == C4OBject )
        {
            foreach(Player, i)
            {
                if(IsPlayerInRangeOfPoint(i, 15, C4Pos[0], C4Pos[1], C4Pos[2]))
                {
                    if(!SKProtection{ i })
                    {
                        OnPlayerDeath(i, playerid, 39);
                        SpawnPlayer(i);
                        GameTextForPlayer(i, "~r~You got C4'd!", 3500, 3);
                    }
                }
                else if(IsPlayerInRangeOfPoint(i, 25, C4Pos[0], C4Pos[1], C4Pos[2]))
                {
                    if(!SKProtection{ i })
                    {
                        SetPlayerHealth(i, 36);
                        SendClientMessage(i, COLOR_RED, "* You got damaged from the C4 blast!");
                    }
                }
                if(PlayerUsedBomb{ i })
                {
                    DestroyObject(C4Object[i]);
                    PlayerUsedBomb{ i } = false;
                    Delete3DTextLabel(C4[i]);
                }
            }
            CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 2, 100);
            CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 3, 100);
            CreateExplosion(C4Pos[0], C4Pos[1]+1, C4Pos[2], 4, 100);
            //Delete3DTextLabel(C4[playerid]);
        }
    }
    return 1;
}
Reply
#6

Just so you know C4 can not be detonated by shooting, burning, or putting it in a microwave

http://en.wikipedia.org/wiki/C-4_(explosive)

"C4 is very stable and insensitive to most physical shocks. C4 cannot be detonated by a gunshot or by dropping it onto a hard surface. It does not explode when set on fire[3] or exposed to microwave radiation.[4] Detonation can only be initiated by a combination of extreme heat and a shockwave, such as when a detonator inserted into it is fired."
Reply
#7

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Just so you know C4 can not be detonated by shooting, burning, or putting it in a microwave
Well.. this gamemode has potato bullets which use black magic and make the C4 explode
+ It would be a nice feature.

Plant / Make a C4 near a cap. zone, wait for someone to go there and boom..
So, any ideas how to fix it? xD
Reply
#8

I think the problem is here if I'm following this correctly.

pawn Код:
if(PlayerUsedBomb{ i })
            {
                DestroyObject(C4Object[i]);
                PlayerUsedBomb{ i } = false;
                Delete3DTextLabel(C4[i]);
            }
That would destroy all players C4 I'm pretty sure.
Reply
#9

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
I think the problem is here if I'm following this correctly.

pawn Код:
if(PlayerUsedBomb{ i })
            {
                DestroyObject(C4Object[i]);
                PlayerUsedBomb{ i } = false;
                Delete3DTextLabel(C4[i]);
            }
That would destroy all players C4 I'm pretty sure.
Yeah.. fixed that now.
Anyways;

Now i can shoot and destroy one C4, but if i try to destroy the 2nd one, it bugs the player again
It keeps telling me "SERVER: Unknown command", even though i have a diff. 'answer' for unknown commands
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)