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

[API/TF2] Need some help with this, Thanks in advance.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
General Lentils
Senior Member
Join Date: Jul 2016
Old 10-21-2016 , 11:12   [API/TF2] Need some help with this, Thanks in advance.
Reply With Quote #1

Hello people yet again, i am still learning about Sourcemod and what the options are with it. But of course there are always a few struggles where you come through.

So. To the point, i have a few questions for the better amongst us. And those are:

1. What is the use of Data/(pack) Cells and how do i use them?

2. What is the use of "Trie"

-----------------------------
3. How can i make this simpler? for example, make a little list of words and then use that argument.
What i mean is like, combining multiple words into 1 single String(word) and then using that as a variable. I made a little script for that so you know what i mean:

------------------------------
PHP Code:
#include <sourcemod>
#pragma tabsize 0

public OnPluginStart()  
{      
    
HookUserMessage(GetUserMessageId("TextMsg"), UserMessageHooktrue);  
}  

public 
Action:UserMessageHook(UserMsg:MsgIdHandle:hBitBuffer, const iPlayers[], iNumPlayersbool:bReliablebool:bInit
{  
    
BfReadByte(hBitBuffer);  
    
decl String:strMessage[1024];  
    
BfReadString(hBitBufferstrMessagesizeof(strMessage));  
    if(
StrContains(strMessage"!") != -1
    { 
        return 
Plugin_Handled
    } 
    if(
StrContains(strMessage"fuck") != -1
    { 
        return 
Plugin_Handled
    } 
    if(
StrContains(strMessage"cunt") != -1
    { 
        return 
Plugin_Handled
    }
    if(
StrContains(strMessage"cancer") != -1
    { 
        return 
Plugin_Handled
    }
    return 
Plugin_Continue;

=======================================> Combining in for example: if (StrContains(strMessage, WordList) != -1)


Thanks in advance! -General Lentils \o/


░█░░░░░░░░░░░░░░░░░░█░
░░█░░░░░░████░░░░░░█░░
░░░█░░░░█░░░░█░░░░█░░░
░░░░█░░█░░░░░░█░░█░░░░
░░░░░█░░█░░░░█░░█░░░░░
░░░░░░██▄████▄██░░░░░░

Last edited by General Lentils; 10-21-2016 at 11:18.
General Lentils is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 10-21-2016 , 14:33   Re: [API/TF2] Need some help with this, Thanks in advance.
Reply With Quote #2

  1. DataPacks are useful when you want to pass multiple values into an asynchronous callback that takes any single value (such as RequestFrame). Pack them together into a DataPack handle, then unpack them on the other side.
  2. A trie (known as StringMap in newer releases) maps strings to values (that is, you can get a value passing in a string, and all strings are unique).
  3. Replace it with an array of strings and iterate over it with a for loop like so:
    Code:
    new String:bannedWords[][] = { "bad", "language", "here" };
    for (new i = 0; i < sizeof(bannedWords); i++) {
        if (StrContains(strMessage, bannedWords[i]) != -1)  { /* ... */ }
    }
    (Note that I'm rusty on old syntax, so you might need to modify the above code for it to compile.)
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 10-21-2016 at 15:16.
nosoop is offline
General Lentils
Senior Member
Join Date: Jul 2016
Old 10-21-2016 , 14:57   Re: [API/TF2] Need some help with this, Thanks in advance.
Reply With Quote #3

Thanks mate, i 'preciate the help!
General Lentils 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 06:45.


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