AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   saytext and /spec problem (https://forums.alliedmods.net/showthread.php?t=205296)

naven 01-09-2013 03:54

saytext and /spec problem
 
Here is my code
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


new points[33];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /rank","check")
    
register_message(get_user_msgid("SayText"),"handleSayText");

}

public 
handleSayText(msgId,msgDest,msgEnt)
{
    new 
id get_msg_arg_int(1);
    if(!
is_user_connected(id))      return PLUGIN_CONTINUE;
    new 
szTmp[256],szTmp2[256];
    
get_msg_arg_string(2,szTmpcharsmaxszTmp ) )
        
    
points[id] = 10;
    new 
szPrefix[64]
    
format(szPrefix63"^x04(%i)",points[id])
    
//new szPrefix[64] = "^x04[VIP]";
        
    
if(!equal(szTmp,"#Cstrike_Chat_All"))
    {        
        
add(szTmp2,charsmax(szTmp2),szPrefix);
        
add(szTmp2,charsmax(szTmp2)," ");
        
add(szTmp2,charsmax(szTmp2),szTmp);//msg
        
    
}
    else if(
equal(szTmp,"#Cstrike_Chat_AllSpec"))// || ( equal(szTmp, "#Cstrike_Chat_Spec") ) )
    
{
        
add(szTmp2,charsmax(szTmp2),szPrefix);
        
add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01: %s2");        
    }
        
add(szTmp2,charsmax(szTmp2),szPrefix);
        
add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01: %s2");
    }
        
    
set_msg_arg_string(2,szTmp2);
        
     
    return 
PLUGIN_CONTINUE;


On my server everyone can see every message from every player. This code works fine, unless I go spectator, then when someone alive is writing, tag won't show up and vice versa. I've tried many things and couldn't get it to work, how do I fix this?

Also I've got another problem.
I've found this code http://forums.alliedmods.net/showpos...61&postcount=7
It was working fine but I've discovered that going spec sometimes blocks the player that I am spectating, it's like I spawn inside spectated player and he can't move. After player is blocked this way it says enemy: playername like he was aiming at me.

Here is the code i'm using right now
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /spec","setSpectate")

}

public 
setSpectateid 
{

    if(
get_cvar_num("surf_allow_spectate") == 1)
    {
        if( !
is_user_alive(id) ) 
        {
            
cs_set_user_team(idCS_TEAM_CTCS_CT_GIGN);
            
dllfunc(DLLFunc_Spawnid);
            return 
PLUGIN_HANDLED;
        }
        else if( 
is_user_alive(id) ) 
        {         
            
strip_user_weapons(id
            
set_pev(idpev_deadflagDEAD_DEAD
        } 
        
engclient_cmd(id"jointeam" "6"//connormcleod
    
}
    else
    {
        
client_print(idprint_chat"%L",LANG_PLAYER,"NO_USE")
    }
    return 
PLUGIN_HANDLED;



naven 01-24-2013 10:11

Re: saytext and /spec problem
 
Any ideas? I need to solve this spectator thing. What i want is when player says /spec he is automatically watching another player in first person view and not free look.

AngeIII 01-24-2013 13:24

Re: saytext and /spec problem
 
didn't see "check" function btw.

also:
add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01: %s2");
}
add(szTmp2,charsmax(szTmp2),szPrefix);
add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01: %s2");
incorrect formatting
("%s %s %s",strin_1,strin_2...)



naven 01-27-2013 08:38

Re: saytext and /spec problem
 
Quote:

Originally Posted by AngeIII (Post 1879586)
didn't see "check" function btw.

Oh, well, I forgot to remove it.

What's wrong about this formatting? I do not understand what you mean. It's working, but I need that to work along with modified admin listen(removed admin access- everyone can see everything).

AngeIII 01-27-2013 13:48

Re: saytext and /spec problem
 
you should write variables..
you write %s1,%s2.. but it's wrong.
for string always: %s
and any of them you should define in variables section.

and also ADD procedure doesn't include formatting.

you should use format/formatex() before.

examle:
PHP Code:

format(str,charsmax(str),"Some value to add %s first variable, %s second",first_variable,second_variable);
add(szTmp2,charsmax(szTmp2),str); 


naven 01-27-2013 14:28

Re: saytext and /spec problem
 
Anyway, I have solved the problem just now. I modified this plugin http://forums.alliedmods.net/showthread.php?t=183491 instead, seems to be working fine. Thank you for your help.

Can you see anything wrong with /spec code?


All times are GMT -4. The time now is 13:43.

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