AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Limit weapon via IP. (https://forums.alliedmods.net/showthread.php?t=129742)

Voltron 06-16-2010 10:32

Limit weapon via IP.
 
Hi all,

I'm trying to implement a system on my server where if a player gets 8 kills in a row they will only be able to use the dual elites for the rest of that map.
So I don't need the players IP or Steam ID saved to a file...just kept in memory so if the player rejoins the map the server will remember that their weapons are limited.

If I want to do this using a players IP address, would I have to use a dynamic array?

hleV 06-16-2010 11:26

Re: Limit weapon via IP.
 
Use SteamID. You can use normal arrays, however it will be restricted to the amount of SteamIDs equal to the size of array. You should use the dynamic ones in this case.

Voltron 06-16-2010 23:42

Re: Limit weapon via IP.
 
Quote:

Originally Posted by hleV (Post 1210507)
Use SteamID. You can use normal arrays, however it will be restricted to the amount of SteamIDs equal to the size of array. You should use the dynamic ones in this case.

Could you give me some example code?

I just need to know how to store the SteamID in an array. And how I would check to see if a players SteamID is in that array.

YamiKaitou 06-17-2010 09:42

Re: Limit weapon via IP.
 
Quote:

Originally Posted by Voltron (Post 1211088)
Could you give me some example code?

Using CellArray
PHP Code:

// Create Array
new Array:array = ArrayCreate(34);


// Store SteamID
new authid[34];
get_user_authid(idauthidcharsmax(authid));
ArrayPushString(array, authid);


// See if SteamID exists
new authid[34];
new 
bool:found false;
new 
k;
new 
size ArraySize(array);
while (
size)
{
    
ArrayGetString(array, k++, authidcharsmax(authid));
    if (
equal(authid"STEAM_0:1:16"))
    {
        
found true;
        break;
    }
}
if (
found)
    
// SteamID found
else
    
// SteamID not found 

Not tested, but should work. There are might be more efficient ways, but this should at least point you in the right direction

xPaw 06-17-2010 10:34

Re: Limit weapon via IP.
 
Yami, Trie would be perfect for this situation, lazy to write example, but he can search around and find what he wants

ConnorMcLeod 06-17-2010 10:35

Re: Limit weapon via IP.
 
Upgrade your nosteam server so you can use steamids :mrgreen:

YamiKaitou 06-17-2010 12:11

Re: Limit weapon via IP.
 
Quote:

Originally Posted by xPaw (Post 1211453)
Yami, Trie would be perfect for this situation, lazy to write example, but he can search around and find what he wants

Never used Trie. What are the benefits?

xPaw 06-17-2010 13:44

Re: Limit weapon via IP.
 
Quote:

Originally Posted by YamiKaitou (Post 1211531)
Never used Trie. What are the benefits?

Just compare to this:

Code:
new Trie:g_tSteamIds; // init g_tSteamIds = TrieCreate( ); // end TrieDestroy( g_tSteamIds ); // add TrieSetString( g_tSteamIds, "STEAM_0:1:16", 1 ); // Hi bailopan! // check TrieKeyExists( g_tSteamIds, "STEAM_0:1:16" ); // delete TrieDeleteKey( g_tSteamIds, "STEAM_0:1:16" );

Voltron 06-17-2010 21:38

Re: Limit weapon via IP.
 
Quote:

Originally Posted by ConnorMcLeod (Post 1211455)
Upgrade your nosteam server so you can use steamids :mrgreen:

It's a hybrid server so I can use SteamIDs too. :P

xPaw, this is the first I've heard of Trie. Interesting.

And thanks for the response guys. I was gonna give you good karma but it looks like it's been removed. lol

fysiks 06-17-2010 21:44

Re: Limit weapon via IP.
 
Quote:

Originally Posted by Voltron (Post 1212070)
It's a hybrid illegal server so I can use SteamIDs too. :P



All times are GMT -4. The time now is 14:47.

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