[Include] ToggleVehicleWeapons -Completely disarm every vehicle !
#1

ToggleVehicleWeaponsV1.0

This script can toggle the weapons for every armed vehicle on/off! I developed a smart method of detecting when a player is about to shoot, this script is using that method to return 0 at OnPlayerUpdate when the player is pressing the shoot keys.

This means you can completely disable the weapons of any vehicle you want!, the bullets or missiles will still be visible for the shooter though, but will NOT spawn serverside (for other players)!

Please note that this does NOT works on miniguns (like the hunter/seasparrow) yet! It will be detected only it will not prevent the shooter from shooting other people ! I succesfully tested this but my test person seems to be altabbed at that moment since it still works :/

Functions
pawn Код:
ToggleVehicleWeaponsForAll(toggle) //toggle for everyone (this will also overwrite PER PLAYER!)
ToggleVehicleWeaponsForPlayer(playerid,toggle); //toggle per player
Callbacks
pawn Код:
OnPlayerVehicleFire(playerid,vehicleid,allowed)
Example script
pawn Код:
#include <a_samp>
#include <nodm>

public OnPlayerVehicleFire(playerid,vehicleid,allowed)
{
    /*
        Callback,
        playerid    = playerid of shooter
        vehicleid   = vehicleid of player
        allowed     = is shot really fired (was it disabled or not, returns 1 when really fired)
    */

    return 1;
}

public OnFilterScriptInit()
{
    ToggleVehicleWeaponsForAll(0); //disarm for everyone
}

// Please note that the following functions MUST be in the script where you include the filterscript to return 1! else they will be called anymore in other scripts
public OnPlayerConnect(playerid)
{
    return 1;
}
public OnPlayerUpdate(playerid)
{

    return 1;
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    return 1;
}
Special thanks to cessil on IRC for helping me fix a small bug (when using multiple keys).
Reply
#2

And have you checked to make sure the bug does not persist when you are holding down that key you can keep out of sync?

If so, very well done.
Reply
#3

Quote:
Originally Posted by Bakr
Посмотреть сообщение
And have you checked to make sure the bug does not persist when you are holding down that key you can keep out of sync?

If so, very well done.
Yes, it only returns 0 at the moment you pressed the key (so not when HOLDING), that seems to disable the weapons as miniguns (like the hunter/seasparrow) as well!

Edit: a friend told me that the minigun still works, just tested it and it seems that my first test person was probably altabbed since it didnt work the first time... going to think about a good solution for this soon. Hydra and hunter missiles will still be blocked succesfully though.
Reply
#4

Nice!

I liked the idea which cancels the OnPlayerUpdate, and I can see this method being used in another scripts.
Reply
#5

wowesome release!!
<3 it
Reply
#6

Can you provide a pastebin link?
Reply
#7

cool,
It can be useful in many areas especially in experience systems etc.
Reply
#8

For what exactly vehicles works this ?
Reply
#9

Quote:
Originally Posted by [Nikk]
Посмотреть сообщение
For what exactly vehicles works this ?
Every vehicle that can shoot rockets (Rhino, Hydra, Hunter etc.). Rockets won't be shown then. It doesn't work for miniguns (Hunter has a minigun aswell, but people can still see you shooting)
Reply
#10

hello,i use the include. but if i use it,the player will be the esc mode.so how to deal with this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)