Raised This Month: $51 Target: $400
 12% 

Adding extra flag for spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anonpiss
Senior Member
Join Date: Jan 2010
Old 02-01-2010 , 23:44   Adding extra flag for spawn
Reply With Quote #1

As you can see at the code below, normal player can only spawn stuff once per life and for admin with z flag can spawn 999. I'd like to add another admin flag to spawn 5, how can I do that?

Code:
public OnPluginStart()
{
    cSpawnAmount = CreateConVar("sm_props_spawnamount", "1", "Normal Player Spawn Limits", FCVAR_PLUGIN);
    cAdminImmune = CreateConVar("sm_props_adminimmune", "z", "Admin  Spawn Limits", FCVAR_PLUGIN);
}

public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    new spawntokens = GetConVarInt(cSpawnAmount);

    decl String:sImmuneFlags[16];
    GetConVarString(cAdminImmune, sImmuneFlags, sizeof(sImmuneFlags));

    if(HasFlag(client, sImmuneFlags))
    {
        g_iClientSpawnCount[client] = 999;
    }
    else
    {
        g_iClientSpawnCount[client] = spawntokens;
    }
}
anonpiss is offline
anonpiss
Senior Member
Join Date: Jan 2010
Old 02-03-2010 , 04:28   Re: Adding extra flag for spawn
Reply With Quote #2

What in the world happened to this community? Apocalypse is coming or what?
anonpiss is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-03-2010 , 08:32   Re: Adding extra flag for spawn
Reply With Quote #3

You should not bother anyone with doing work for you that you could yourself if you just would study the sourcemod docs and learn scripting.

It's not really hard to add a second convar and add another else if statement.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 02-03-2010 , 12:52   Re: Adding extra flag for spawn
Reply With Quote #4

or use a switch statement
__________________
toazron1 is offline
Send a message via AIM to toazron1
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 02-03-2010 , 18:44   Re: Adding extra flag for spawn
Reply With Quote #5

A switch on what variable? The only values being compared are bools.

Code:
if(HasFlag(client, sImmuneFlags))
    {
        g_iClientSpawnCount[client] = 999;
    }
    else if (HasFlag(client, "whateverflag"))
    {
    }
    else
    {
        g_iClientSpawnCount[client] = spawntokens;
    }
__________________
Greyscale is offline
anonpiss
Senior Member
Join Date: Jan 2010
Old 02-03-2010 , 20:47   Re: Adding extra flag for spawn
Reply With Quote #6

Thanks Greyscale.
anonpiss is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 02-04-2010 , 00:34   Re: Adding extra flag for spawn
Reply With Quote #7

I was thinking a larger scale with several flags, if you just want to add one more flag ifelse is the way to go.
__________________
toazron1 is offline
Send a message via AIM to toazron1
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 00:42.


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