Raised This Month: $32 Target: $400
 8% 

Remove and Set Weapon ammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joneco
Junior Member
Join Date: Jul 2013
Old 09-13-2013 , 11:55   Remove and Set Weapon ammo
Reply With Quote #1

Hi i wanna know how to avoid player shooting in buyzone.
I'm doing a surf plugin and i put to protect players in buyzone.
Now i want to avoid them to stop when is in buyzone.
So i thought that:
when entered in buyzone ammo will be 0 of any weapon.
when you get out it will be set to 90 or 100... for every weapon to avoid problems...

someone can help me with that code? or if it is another possibility instead of removing ammo it will be fine too =)

thanks
joneco is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 09-13-2013 , 12:20   Re: Remove and Set Weapon ammo
Reply With Quote #2

Try this

No damage in buy zone
Attached Files
File Type: sp Get Plugin or Get Source (buyzone_nodamage.sp - 296 views - 729 Bytes)
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 09-13-2013 at 12:23.
Franc1sco is offline
Send a message via MSN to Franc1sco
joneco
Junior Member
Join Date: Jul 2013
Old 09-13-2013 , 12:42   Re: Remove and Set Weapon ammo
Reply With Quote #3

Quote:
Originally Posted by Franc1sco View Post
Try this

No damage in buy zone
i want to avoid people from buy zone shooting in people outside the buyzone...

i tried to use smlib but i get ammo bugged O_o. now m4a1 has the first clip with 250 bullets hahaha

i tried this ones

Client_SetWeaponPlayerAmmo(client, "weapon_m4a1", 0);
Client_SetWeaponAmmo(client, "weapon_m4a1", 0, 0);
joneco is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 09-13-2013 , 12:55   Re: Remove and Set Weapon ammo
Reply With Quote #4

SDKHooks OnTakeDamage might be userful
Unfortunely i can't currently bring out example / snippet

Also if it's CS:GO those two events might be also handy
enter_buyzone
exit_buyzone
__________________
...
Oshizu is offline
joneco
Junior Member
Join Date: Jul 2013
Old 09-13-2013 , 14:13   Re: Remove and Set Weapon ammo
Reply With Quote #5

Quote:
Originally Posted by Oshizu View Post
SDKHooks OnTakeDamage might be userful
Unfortunely i can't currently bring out example / snippet

Also if it's CS:GO those two events might be also handy
enter_buyzone
exit_buyzone
i'm using this events... it working fine.
but i do not know how can i remove weapon ammo and when the player exit buyzone i put it back... or maybe make they can not shoot...
joneco is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 09-13-2013 , 15:56   Re: Remove and Set Weapon ammo
Reply With Quote #6

Here is code reducing damages if attacker is in buyzone
PHP Code:
#include <sdkhooks>

new CannotAttack[MAXPLAYERS+1] = false;

public 
OnClientPutInServer(client)
{
    
CannotAttack[client] = false;
    
SDKHook(clientSDKHook_OnTakeDamageOnClientTakeDamage);
}

public 
Action:OnClientTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    if(
attacker 0)
    {
        if(
CannotAttack[attacker])
        {
            
damage 0.0
            PrintToChat
(attacker"[SM] You cannot attack while you are in Buy Zone")
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;
}

public 
OnPluginStart()
{
    
HookEvent("enter_buyzone"Enter_BuyZoneEventHookMode_Post)
    
HookEvent("exit_buyzone"Exit_BuyZoneEventHookMode_Post)
    
HookEvent("player_death"PlayerEventsEventHookMode_Post)
    
HookEvent("player_spawn"PlayerEventsEventHookMode_Post)
}

public 
Action:Enter_BuyZone(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
CannotAttack[client] = true
}

public 
Action:Exit_BuyZone(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
CannotAttack[client] = false
}

public 
Action:PlayerEvents(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
CannotAttack[client] = false

__________________
...

Last edited by Oshizu; 09-13-2013 at 16:01.
Oshizu is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode