PDA

View Full Version : Limit weapon via IP.


Voltron
06-16-2010, 10:32
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
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
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
Could you give me some example code?


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


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


// See if SteamID exists
new authid[34];
new bool:found = false;
new k;
new size = ArraySize(array);
while (k < size)
{
ArrayGetString(array, k++, authid, charsmax(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
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
Upgrade your nosteam server so you can use steamids :mrgreen:

YamiKaitou
06-17-2010, 12:11
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
Never used Trie. What are the benefits?
Just compare to this:

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
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
It's a hybrid illegal server so I can use SteamIDs too. :P