AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting part of a StatusText? (https://forums.alliedmods.net/showthread.php?t=60055)

M249-M4A1 08-26-2007 00:12

Getting part of a StatusText?
 
What I'm trying to do is use StatusText to report what class a spy has disguised into. I have been using this very inefficient piece of code:

Code:

register_event("StatusText", "CLASS_SCOUT", "b", "2&#Spy_disguised Blue #Scout")
Is there a way to hook the message by ignoring the team's name, and only reading what class comes after it?

hlstriker 08-26-2007 12:33

Re: Getting part of a StatusText?
 
Here is just an example of getting what class a player disguised to.

PHP Code:

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_event("StatusText""hook_StatusText""b""2&Spy_disguised");
}

public 
hook_StatusText(id)
{
    new 
arg2[64];
    
read_data(2arg263);
    
    if(
containi(arg2"Scout") != -1)
    {
        
// Disguised as Scout
    
}
    else if(
containi(arg2"Sniper") != -1)
    {
        
// Disguised as Sniper
    
}
    else if(
containi(arg2"Soldier") != -1)
    {
        
// Disguised as Soldier
    
}
    else if(
containi(arg2"Demoman") != -1)
    {
        
// Disguised as Demoman
    
}
    else if(
containi(arg2"Medic") != -1)
    {
        
// Disguised as Medic
    
}
    else if(
containi(arg2"HWGuy") != -1)
    {
        
// Disguised as HWGuy
    
}
    else if(
containi(arg2"Pyro") != -1)
    {
        
// Disguised as Pyro
    
}
    else if(
containi(arg2"Spy") != -1)
    {
        
// Disguised as Spy
    
}
    else if(
containi(arg2"Engineer") != -1)
    {
        
// Disguised as Engineer
    
}



M249-M4A1 08-26-2007 17:39

Re: Getting part of a StatusText?
 
Thank you so much striker! I tried that same method first, but I never did the != -1 part! +Karma for your help!


All times are GMT -4. The time now is 16:15.

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