[Tutorial] How to make a kickgun, for admins only
#1

Hello,

I've been asked to post this on here, Other people that can't get the Kickgun working.


This is the main script, that kicks "damageid" when you shoot them with the kickgun.
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if(GetPlayerWeapon(playerid) == 33 && kickgun[playerid] == 1) {
	SendClientMessage(damagedid,COLOR_RED, "You have been kicked by The Quake Industries Shotgun for AFK.");
	Kick(damagedid);
	
	}
	return 1;
}
This is the actual kickgun script, I just put this below some other command, using strcmp.

Код:
	if(strcmp(cmd, "/kickgun", true) ==0)
	{
	    if(PlayerInfo[playerid][pAdmin] >= 1337)
	    {
			if(kickgun[playerid] == 0)
			{
				if(PlayerInfo[playerid][pKGBullets] != 0)
				{
					SafeGivePlayerWeapon(playerid, 33, 10000);
 					SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1000);
					kickgun[playerid] = 1;
					
					format(string, sizeof(string), "* %s Takes out his kickgun.", sendername);
					ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY,"* No charges in the kickgun!");
				    return 1;
				}
			}
			else
			{
			    ResetPlayerWeapons(playerid);
				SafeGivePlayerWeapon(playerid, 24, 10);
				AttachWeaponCorrectly(playerid, 23);
				kickgun[playerid] = 0;
				ClearAnimations(playerid);
				SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, PlayerInfo[playerid][pSilenSkill]);
				format(string, sizeof(string), "* %s Puts his kickgun away.", sendername);
				ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
			}
		}
	    return 1;
	}
Hope you like.
Reply
#2

Not a tutorial, don't post this here. Should be in something like "Useful snippets".

And I do not know what kind of people would use this, only people who like to shoot people and kick them for fun.
Reply
#3

Quote:

public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)

Why under OnPlayerGiveDamage?

Quote:

if(GetPlayerWeapon(playerid) == 33 && kickgun[playerid] == 1) {

What's that? What it should do? Oh wait! I got an error here.

Quote:

SendClientMessage(damagedid,COLOR_RED, "You have been kicked by The Quake Industries Shotgun for AFK.");

DAMN! wtf was that? Can you explain more? Oh i got another error here!

Quote:

if(PlayerInfo[playerid][pAdmin] >= 1337)

Damn, another error and can you tell me how to fix this?

Quote:

if(PlayerInfo[playerid][pKGBullets] != 0)
{
SafeGivePlayerWeapon(playerid, 33, 10000);

What it should do? Btw, I got a LOT of errors here.

Quote:

ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,CO LOR_CHAT5);

ProxDetector? I can't find it on sa-mp wiki. Where did you get it?

Quote:

AttachWeaponCorrectly(playerid, 23);

Hmm can you explain this?
Reply
#4

This is pasted from the RP server lmao.
Reply
#5

Untested but better than OP

pawn Код:
#include <a_samp>
#include <zcmd>

#define KICK_GUN 38

new bool:HasKickGun[MAX_PLAYERS];

stock TogglePlayerKickGun(playerid, toggle)
{
    switch(toggle)
    {
        case 0:
        {
            new gun, ammo;
            new GunArray[13][2];
            for(new i=0; i<13; i++)
            {
                GetPlayerWeaponData(playerid, i, gun, ammo);
                GunArray[i][0] = gun;
                GunArray[i][1] = ammo;
            }
            ResetPlayerWeapons(playerid);
           
            for(new i=0; i<13; i++)
            {
                if(GunArray[i][0] != KICK_GUN)
                {
                    GivePlayerWeapon(playerid, GunArray[i][0], GunArray[i][0]);
                }
            }
            SendClientMessage(damagedid, 0xFFFFFFFF, ">> KickGun DISABLED");
            HasKickGun[playerid] = false;
        }
       
        case 1:
        {
            GivePlayerWeapon(playerid, KICK_GUN, 35525);
            SendClientMessage(damagedid, 0xFFFFFFFF, ">> KickGun ENABLED");
            HasKickGun[playerid] = true;
        }
    }
}

public OnPlayerConnect(playerid)
{
    HasKickGun[playerid] = false;
    return 1;
}

public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
    if(HasKickGun[playerid] && weaponid == KICK_GUN)
    {
        SendClientMessage(damagedid, 0xFFFFFFFF, ">> You were kicked by the kickgun");
        Kick(damagedid);
    }
    return 1;
}

CMD:KickGun(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        if(HasKickGun[playerid])
        {
            TogglePlayerKickGun(playerid, 0);
        }
        else
        {
            TogglePlayerKickGun(playerid, 1);
        }
    }
    else
    {
        SendClientMessage(damagedid, 0xFFFFFFFF, ">> No KickGun for you!");
    }
    return 1;
}
Reply
#6

I am surprised you even call this a tutorial
Read this please
Reply
#7

Quote:
Originally Posted by UnknownGamer
Посмотреть сообщение
Hello,

I've been asked to post this on here, Other people that can't get the Kickgun working.


This is the main script, that kicks "damageid" when you shoot them with the kickgun.
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    if(GetPlayerWeapon(playerid) == 33 && kickgun[playerid] == 1) {
	SendClientMessage(damagedid,COLOR_RED, "You have been kicked by The Quake Industries Shotgun for AFK.");
	Kick(damagedid);
	
	}
	return 1;
}
This is the actual kickgun script, I just put this below some other command, using strcmp.

Код:
	if(strcmp(cmd, "/kickgun", true) ==0)
	{
	    if(PlayerInfo[playerid][pAdmin] >= 1337)
	    {
			if(kickgun[playerid] == 0)
			{
				if(PlayerInfo[playerid][pKGBullets] != 0)
				{
					SafeGivePlayerWeapon(playerid, 33, 10000);
 					SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1000);
					kickgun[playerid] = 1;
					
					format(string, sizeof(string), "* %s Takes out his kickgun.", sendername);
					ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY,"* No charges in the kickgun!");
				    return 1;
				}
			}
			else
			{
			    ResetPlayerWeapons(playerid);
				SafeGivePlayerWeapon(playerid, 24, 10);
				AttachWeaponCorrectly(playerid, 23);
				kickgun[playerid] = 0;
				ClearAnimations(playerid);
				SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, PlayerInfo[playerid][pSilenSkill]);
				format(string, sizeof(string), "* %s Puts his kickgun away.", sendername);
				ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
			}
		}
	    return 1;
	}
Hope you like.
This wouldn't work and would give a few errors especially since it was copied and pasted and needs to be set up correctly. Could have at least credited me in it.

So to fix a few errors:
Firstly, you haven't referenced kickgun nor KGBullets.
SetPlayerSkillLevel wouldn't even be required as it was specific to our game mode
I would go on, however I rather just post the new version I created since the only thing you changed was the weapon that you received when using the command and the Quake industry stuff.

So yeah, I'll repost the my version as either an include or a filsterscript either today or tomorrow.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)