[FilterScript] Drop Gun
#1

Drop Gun
Description

You can drop a gun on the floor using the command /dropgun and pick it up using /pickupgun. Oh, it also drops your weapon on death.

Pic: http://i53.tinypic.com/2556heg.png

AMX: http://www.2shared.com/file/fRWgZyGm/dropgun.html
It's too small to put it on pastebin
pawn Код:
// This is a comment.
// ^^lol a comment.
//=================//
#include <a_samp>// by SA-MP
#include <streamer>// by Incognito
#include <zcmd>// by Zeex
#include <foreach>// by ******
//=================//
#define MAX_DROP_ITEMS 1000//Change it to set the max weapons that can be dropped.
#define COLOR_ACTION 0xFFC0CBFF//Gay Pink Color
//=================//
new string[128], sendername[MAX_PLAYER_NAME], DropObject[MAX_DROP_ITEMS];
//=================//
enum dData
{
    DropGunAmmount[2],//ModelID & Bullets
    Float:DropGunPosX,
    Float:DropGunPosY,
    Float:DropGunPosZ,
    DropGunVWorld,
    DropGunInterior,
};
new DropInfo[MAX_DROP_ITEMS][dData];
//=================//
new GunObjectIDs[200] ={

   1575,  331, 333, 334, 335, 336, 337, 338, 339, 341, 321, 322, 323, 324, 325, 326, 342, 343, 344, -1,  -1 , -1 ,
   346, 347, 348, 349, 350, 351, 352, 353, 355, 356, 372, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367,
   368, 369, 1575
};
//=================//
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Drop Gun FS by a fat guy.....Loaded!!!");
    print("--------------------------------------\n");
    return 1;
}
//=================//
stock GetGunObjectID(WeaponID)
{
    if (WeaponID < 0 || WeaponID > 64)
    {
        return 1575;
    }
    return GunObjectIDs[WeaponID];
}
//=================//
stock DropGun(playerid, GunID, GunAmmo, Float:X, Float:Y, Float:Z, world, interior)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if(GunID != 0 && GunAmmo != 0)
    {
        for(new i = 0; i < sizeof(DropInfo); i++)
        {
            if(DropInfo[i][DropGunPosX] == 0.0 && DropInfo[i][DropGunPosY] == 0.0 && DropInfo[i][DropGunPosZ] == 0.0)
            {
                DropInfo[i][DropGunAmmount][0] = GunID;
                DropInfo[i][DropGunAmmount][1] = GunAmmo;
                DropInfo[i][DropGunPosX] = X;
                DropInfo[i][DropGunPosY] = Y;
                DropInfo[i][DropGunPosZ] = Z;
                DropInfo[i][DropGunVWorld] = world;
                DropInfo[i][DropGunInterior] = interior;
                DropObject[i] = CreateDynamicObject(GetGunObjectID(GunID), X, Y, Z-1, 80.0, 0.0, 0.0, world);
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
//=================//
stock RemovePlayerWeapon(playerid, weaponid)//Credits to Xalphox
{
    if(!IsPlayerConnected(playerid) || weaponid < 0 || weaponid > 50)
        return;
    new saveweapon[13], saveammo[13];
    for(new slot = 0; slot < 13; slot++)
        GetPlayerWeaponData(playerid, slot, saveweapon[slot], saveammo[slot]);
    ResetPlayerWeapons(playerid);
    for(new slot; slot < 13; slot++)
    {
        if(saveweapon[slot] == weaponid || saveammo[slot] == 0)
            continue;
        GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]);
    }

    GivePlayerWeapon(playerid, 0, 1);

}
//=================//
public OnFilterScriptExit()
{
    print("Drop Gun FS by a fat guy.....Unloaded :( ");
    return 1;
}
//=================//
public OnPlayerDeath(playerid, killerid, reason)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    DropGun(playerid, GetPlayerWeapon(playerid),GetPlayerAmmo(playerid),X,Y,Z,GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
    return 1;
}
//=================//
command(dropgun, playerid, params[])
{
    new Float:X,Float:Y,Float:Z;
    new GunID = GetPlayerWeapon(playerid);
    new GunAmmo = GetPlayerAmmo(playerid);
    GetPlayerName(playerid, sendername, sizeof(sendername));
    GetPlayerPos(playerid, X, Y, Z);
    RemovePlayerWeapon(playerid, GunID);
    DropGun(playerid, GunID,GunAmmo,X,Y,Z,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
    format(string, sizeof(string), "* %s drops his weapon to the pavement.", sendername);
    SendLocalMessage(playerid, string, 10.0, COLOR_ACTION, COLOR_ACTION);
    return 1;
}
//=================//
command(pickupgun, playerid, params[])
{
    for(new i = 0; i < sizeof(DropInfo); i++)
    {
        if (IsPlayerInRangeOfPoint(playerid, 2.0,DropInfo[i][DropGunPosX],DropInfo[i][DropGunPosY],DropInfo[i][DropGunPosZ]))
        {
            if(GetPlayerVirtualWorld(playerid) == DropInfo[i][DropGunVWorld] && GetPlayerInterior(playerid) == DropInfo[i][DropGunVWorld])
            {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                DestroyDynamicObject(DropObject[i]);
                DropInfo[i][DropGunPosX] = 0.0;
                DropInfo[i][DropGunPosY] = 0.0;
                DropInfo[i][DropGunPosZ] = 0.0;
                DropInfo[i][DropGunAmmount][0] = 0;
                DropInfo[i][DropGunAmmount][1] = 0;
                GivePlayerWeapon(playerid,DropInfo[i][DropGunAmmount][0],DropInfo[i][DropGunAmmount][1]);
                format(string, sizeof(string), "* %s picks up a weapon from the pavement.", sendername);
                SendLocalMessage(playerid, string, 10.0, COLOR_ACTION, COLOR_ACTION);
                return 1;
            }
        }
    }
    return 1;
}
//=================//
stock SendLocalMessage(playerid, msg[], Float:MessageRange, Range1color, Range2color)
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ;
    GetPlayerPos(playerid, PlayerX, PlayerY, PlayerZ);
    foreach (Player, i)
    {
        if(IsPlayerInRangeOfPoint(i, MessageRange, PlayerX, PlayerY,PlayerZ))
        {
            SendClientMessage(i, Range1color, msg);
        }
        else if(IsPlayerInRangeOfPoint(i, MessageRange/2.0, PlayerX, PlayerY,PlayerZ))
        {
            SendClientMessage(i, Range2color, msg);
        }
    }
}

Credits

SA-MP Developers(Past, Current and future ones) - For making everything possible/
Incognito - Streamer Plugin https://sampforum.blast.hk/showthread.php?tid=102865
Zeex - zcmd https://sampforum.blast.hk/showthread.php?tid=91354
****** - foreach https://sampforum.blast.hk/showthread.php?tid=92679
Xalphox - RemovePlayerWeapon
Freshkilla(PR-RP) - Idea and no I did not use any part of you code.
Reply
#2

Nice work, easy and fun

Edit:


RemovePlayerWeapon(playerid, weaponid)

I think ryder made a function like that, you shud credit him
Reply
#3

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Nice work, easy and fun

Edit:


RemovePlayerWeapon(playerid, weaponid)

I think ryder made a function like that, you shud credit him
Xalphox actually, I forgot to add him, added him now.
Reply
#4

dude i dont have the includes except streamer where can i get them? besides a_samp of course
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=92679

https://sampforum.blast.hk/showthread.php?tid=91354
Reply
#6

when i use foreach i get this when i compile it

C:\Users\Legit_V20\Desktop\GTASanAndreas\pawno\inc lude\foreach.inc(140) : fatal error 111: user error: "Please include a_samp or a_npc before foreach"


Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#7

i dont see why an include is in pastebin?
Reply
#8

Quote:
Originally Posted by Legit_V20
Посмотреть сообщение
when i use foreach i get this when i compile it

C:\Users\Legit_V20\Desktop\GTASanAndreas\pawno\inc lude\foreach.inc(140) : fatal error 111: user error: "Please include a_samp or a_npc before foreach"


Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
WTF Never seen that before.

Anyways here is the .amx, dunno why you can't compile it AMX: http://www.2shared.com/file/fRWgZyGm/dropgun.html

or just comment out foreach and change the last function to this


pawn Код:
stock SendLocalMessage(playerid, msg[], Float:MessageRange, Range1color, Range2color)
{
    new Float: PlayerX, Float: PlayerY, Float: PlayerZ;
    GetPlayerPos(playerid, PlayerX, PlayerY, PlayerZ);
    for(new i = 0; i < MAX_PLAYERS; i ++ )
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, MessageRange, PlayerX, PlayerY,PlayerZ))
            {
                SendClientMessage(i, Range1color, msg);
            }
            else if(IsPlayerInRangeOfPoint(i, MessageRange/2.0, PlayerX, PlayerY,PlayerZ))
            {
                SendClientMessage(i, Range2color, msg);
            }
        }
    }
}
Reply
#9

nevermind i fixed it lol thanks a lot for the script bro, its great
Reply
#10

thanks
Reply
#11

Nice fs very useful and simple !
Reply
#12

The codes and the way the functions are lined up look very similar to the leaked script that was out without my permission you sure you just took that script and fixed it up?, Not trying to make a big deal out of it if it's true then could i please get my credits.
Reply
#13

Indeed, Fresh- I was just about to point that out.

Quote:

Freshkilla(PR-RP) - Idea and no I did not use any part of you code.

Unfortunately, having read both scripts the code is 90% the same with a few edits to the enum and that's about it. PeteShag I'll be more warey about what you release in future, it was a major concern when members of the forums got ahold of the PR:RP script. Only takes one person to read the code and prove you didn't write this at all.
Reply
#14

This is great for TDM! ...(as well as RP maybe) but I've always wanted a TDM server where you drop weapons when you die, and then others can take them and use them to their advantage I used to play TDM in Killzone on PS2 - the most awesome fps game I've ever played. I loved to kill someone just to take their weapon xD it could be bazooka, minigun or the The M327 Grenade Launcher manufactured by ISA Laboratories! xD good job..
Reply
#15

Hello i impleated this FS to my gm and i got one problem (my gamemode fault) so if someone know where is the problem help me please.
PROBLEM: When i drop gun and then pick it up it doesnt shows but at my stats it show that i have it. Where can be a problem ?
Reply
#16

i didnt have any errors but i do have two warnings


Код:
pawno\include\streamer.inc(419) : warning 202: number of arguments does not match definition
pawno\include\streamer.inc(433) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

2 Warnings.
Reply
#17

Quote:
Originally Posted by MEC
Посмотреть сообщение
i didnt have any errors but i do have two warnings


Код:
pawno\include\streamer.inc(419) : warning 202: number of arguments does not match definition
pawno\include\streamer.inc(433) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

2 Warnings.
Hmm, have you changed the "streamer.inc" include?
Reply
#18

Quote:
Originally Posted by VoViNaToR
Посмотреть сообщение
Hello i impleated this FS to my gm and i got one problem (my gamemode fault) so if someone know where is the problem help me please.
PROBLEM: When i drop gun and then pick it up it doesnt shows but at my stats it show that i have it. Where can be a problem ?
Are you using a custom function to give a player a gun, most likely used for an anti-cheat?

Quote:
Originally Posted by MEC
Посмотреть сообщение
i didnt have any errors but i do have two warnings


Код:
pawno\include\streamer.inc(419) : warning 202: number of arguments does not match definition
pawno\include\streamer.inc(433) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

2 Warnings.
I've complied perfectly with the latest streamer on 0.3c. Be sure your up-to-date as well.
Reply
#19

very nice!
Reply
#20

Looks good
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)