PDA

View Full Version : more than 2 smokegrenades?


tobi187
01-20-2012, 17:26
Hi out there!

I have s simple question.

In the search function, there wasnt any "real helping" thing.

Ive searched for a way, players get 2 smokegrenades on spawn.
I dont think of giving him one and if he throws it, he gets another.
Im thinking of giving him 2 on spawn. I know theres some way, cause you can do it with eventscripts (Some CSBase entitiy stuff).

Cause im all new, well not entirely new to sourcemod (using it since a few months) my skills arent that great. And even ive nothing found on the wiki at all.

So i ask you, is there a way?

Thx for your help

and im sorry for my baaad english :D

TnTSCS
01-20-2012, 17:53
you want to just "give" them two when they spawn or allow them to buy two?

The CVar has been fixed - ammo_smokegrenade_max 2

That will allow all players the ability to buy two smoke grenades :)

tobi187
01-21-2012, 11:51
Thank you :)

Yes i want to allow them buying 2 smokegrenades.

Is there a possibility to set the cvar per client?

Want to use it for a VIP script

Bacardi
01-21-2012, 13:40
Dunno you like this
Lucky I found bl4nk code to look ammo offsets

- Plugin check have server cvar ammo_smokegrenade_max bigger than 1
- Look is player in buyzone
- When try buying smokegrenade, check player ammo offset what he have already
Then check has he admin priviledge allow to buy.

Hope you figure it yourself.

new ammoOffset;
new Handle:ammo_smokegrenade_max = INVALID_HANDLE;
new bool:enable = false;

public OnPluginStart()
{
if((ammoOffset = FindSendPropInfo("CCSPlayer", "m_iAmmo")) == -1)
{
SetFailState("Not found offset CCSPlayer:m_iAmmo");
}

if((ammo_smokegrenade_max = FindConVar("ammo_smokegrenade_max")) == INVALID_HANDLE)
{
SetFailState("Not found cvar ammo_smokegrenade_max");
}

HookConVarChange(ammo_smokegrenade_max, convar_change);
enable = GetConVarInt(ammo_smokegrenade_max) > 1 ? true:false // If server allow buy more than 1 smokegrenade, plugin start work

AddCommandListener(buy, "buy"); // Keep look players buy cmd
}

public convar_change(Handle:convar, const String:oldValue[], const String:newValue[])
{
enable = GetConVarInt(ammo_smokegrenade_max) > 1 ? true:false
}

public Action:buy(client, const String:command[], argc)
{
if(enable && GetEntProp(client, Prop_Send, "m_bInBuyZone")) // Players can buy more than 1 smokegrenade and in buyzone (is alive also)
{
new String:buffer[15];
GetCmdArgString(buffer, sizeof(buffer));

if(StrEqual(buffer, "smokegrenade", false))
{
/*
// thanks blank http://forums.alliedmods.net/showpost.php?p=724943&postcount=8
for (new i = 0; i < 32; i++)
{
PrintToConsole(client, "Offset: %i - Count: %i", i, GetEntData(client, ammoOffset+(i*4)));
}
*/

new has = GetEntData(client, ammoOffset+(13*4)); // How much smokegrenades player got already

if(has >= 1 && !CheckCommandAccess(client, "vip_smoke", ADMFLAG_RESERVATION)) // Player have already 1 or more smokegrenades and not priviledge buy more, prevent buying.
{
//PrintCenterText(client, "You cannot carry any more.");
PrintCenterText(client, "Only VIP can buy more.");
return Plugin_Handled;
}
}
}
return Plugin_Continue;
}

So this only prevent buy smokegrenades, not carry what they find from gound.

TnTSCS
01-21-2012, 15:04
My GrenadePack2 (http://forums.alliedmods.net/showthread.php?p=1597248)plugin allows server admins to give VIP players more nades...

I'm working on finalizing it to keep non-VIP players from being able to pickup more than what they're allowed... right now, it only restricts them from purchasing more than they're allowed.

...:: TnT Edit ::...

Wait a minute - maybe my plugin already does this - testing is in order :)

tobi187
01-21-2012, 17:14
Just throwing in 2 props:

CBasePlayer.localdata.m_iAmmo.002 90


and


CBasePlayer m_iAmmo

I had an eventscript for this, few months ago. searched it on the rootservers but it isnt there any more...

it just sets the smokegrenade limit to 2, like if you wouldnt give anyone a smoke, you can just buy 2 and they are shown in your hud as well.

It was some CBase prop, and it was 1 line of code.

Hoped i had saved it for this moment

TnTSCS
01-21-2012, 17:17
valve has this CVar - ammo_smokegrenade_max...

but my plugin gives VIPs more treatment

tobi187
01-21-2012, 17:27
yeah alright.

But it shouldnt prevent non VIP from purchasing more than 1 nade, if they can normally. (like buying one, throwing one and rebuying after that - should even work!) And VIP can carry 2 smokegrenades...

btw CBasePlayer.localdata.m_iAmmo.013 was the prop for smokegrenades

TnTSCS
01-21-2012, 23:18
Updated the GrenadePack2 (http://forums.alliedmods.net/showthread.php?p=1597248) plugin.

I think it will satisfy your needs. Let me know :)

tobi187
01-22-2012, 06:58
Thanks a lot :)