Две ошибки в разных плагина [Исправить]

Тема в разделе "Программирование / Скриптинг", создана пользователем B1g, 24 окт 2015.

  1. B1g

    B1g

    Сообщения:
    732
    Симпатии:
    27
    Первая ошибка и исход плагина:
    L 10/18/2015 - 14:57:53: [SM] Native "IsClientInGame" reported: Client index 0 is invalid
    L 10/18/2015 - 14:57:53: [SM] Displaying call stack trace for plugin "Rank Info - Smoke.smx":
    L 10/18/2015 - 14:57:53: [SM] [0] Line 24, C:\Users\јртем\Desktop\сервер\addons\sourcemod\scripting\Rank Info - Smoke.sp::RankCallback()
    PHP:
    public OnPluginStart()
    {
        
    HookEvent("player_spawn"Event_PS);
    }

    public 
    Event_PS(Handleevent , const Stringname[] , booldontBroadcast)
    {
        
    RankMe_GetRank(GetClientOfUserId(GetEventInt(event,"userid")),RankCallback);
    }

    public 
    RankCallback(clientrankany:data)
    {
        if(
    IsClientInGame(client))
        {
            
    PrintToChat(client"\x04[RANK-ME]\x01  Вы сейчас на \x03%d\x01 месте с \x03%d\x01 очками.",rank,RankMe_GetPoints(client));
        }  
    }
    Вторая ошибка и исход плагина:
    L 10/17/2015 - 19:14:07: [SM] Native "GetClientName" reported: Client 6 is not connected
    L 10/17/2015 - 19:14:07: [SM] Displaying call stack trace for plugin "rankme_connect_announcer.smx":
    L 10/17/2015 - 19:14:07: [SM] [0] Line 190, C:\Users\јртем\Desktop\сервер\addons\sourcemod\scripting\rankme_connect_announcer.sp::RankConnectCallback()
    PHP:
    #pragma semicolon  1
    #include <sourcemod>
    #include <rankme>
    #include <colors>

    #define PLUGIN_VERSION "r6"

    #define MSG "\x04[RankMe]: \x01"

    new Handle:g_cvarAnnounceConnect;
    new 
    Handle:g_cvarAnnounceConnectCenter;
    new 
    Handle:g_cvarAnnounceConnectChat;
    new 
    Handle:g_cvarAnnounceConnectHint;
    new 
    Handle:g_cvarAnnounceDisconnect;
    new 
    Handle:g_cvarAnnounceTopConnect;
    new 
    Handle:g_cvarAnnounceTopPosConnect;
    new 
    Handle:g_cvarAnnounceTopConnectCenter;
    new 
    Handle:g_cvarAnnounceTopConnectChat;
    new 
    Handle:g_cvarAnnounceTopConnectHint;

    new 
    bool:g_bAnnounceConnect;
    new 
    bool:g_bAnnounceConnectCenter;
    new 
    bool:g_bAnnounceConnectChat;
    new 
    bool:g_bAnnounceConnectHint;
    new 
    bool:g_bAnnounceDisconnect;
    new 
    bool:g_bAnnounceTopConnect;
    new 
    bool:g_bAnnounceTopConnectCenter;
    new 
    bool:g_bAnnounceTopConnectChat;
    new 
    bool:g_bAnnounceTopConnectHint;

    new 
    g_AnnounceTopPosConnect;

    new 
    g_aPointsOnConnect[MAXPLAYERS+1];
    new 
    g_aPointsOnDisconnect[MAXPLAYERS+1];
    new 
    g_aRankOnConnect[MAXPLAYERS+1];
    new 
    String:g_sBufferClientName[MAXPLAYERS+1][MAX_NAME_LENGTH];

    public 
    Plugin:myinfo = {
        
    name "RankMe Connect Announcer",
        
    author "lok1",
        
    description "",
        
    version PLUGIN_VERSION,
        
    url ""
    };

    public 
    OnPluginStart(){

        
    // Create the cvars
        
    g_cvarAnnounceConnect CreateConVar("rankme_announcer_player_connect","1","Announce when a player connect with position and points?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceConnectCenter CreateConVar("rankme_announcer_player_connect_center","0","Announce when a player connect at center?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceConnectChat CreateConVar("rankme_announcer_player_connect_chat","1","Announce when a player connect at chat?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceConnectHint CreateConVar("rankme_announcer_player_connect_hint","0","Announce when a player connect at hintbox?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceDisconnect CreateConVar("rankme_announcer_player_disconnect","1","Announce when a player disconnect with position and points?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceTopConnect CreateConVar("rankme_announcer_top_player_connect","1","Announce when a top player connect?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceTopPosConnect CreateConVar("rankme_announcer_top_pos_player_connect","10","Max position to announce that a top player connect?",_,true,0.0);
        
    g_cvarAnnounceTopConnectCenter CreateConVar("rankme_announcer_top_player_connect_center","1","Announce when a top player connect at center?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceTopConnectChat CreateConVar("rankme_announcer_top_player_connect_chat","1","Announce when a top player connect at chat?",_,true,0.0,true,1.0);
        
    g_cvarAnnounceTopConnectHint CreateConVar("rankme_announcer_top_player_connect_hint","0","Announce when a top player connect at hintbox?",_,true,0.0,true,1.0);
        
        
    // Load the config file
        
    AutoExecConfig(true,"rankme_connect_announcer");

        
    // Hook the cvars changes
        
    HookConVarChange(g_cvarAnnounceConnect,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceConnectCenter,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceConnectChat,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceConnectHint,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceDisconnect,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceTopConnect,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceTopPosConnect,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceTopConnectCenter,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceTopConnectChat,ConVarChanged);
        
    HookConVarChange(g_cvarAnnounceTopConnectHint,ConVarChanged);
        
        
    // Load the translations
        
    LoadTranslations("rankme_connect_announcer.phrases");
        
        
    // Create version cvar
        
    new Handle:cvarVersion CreateConVar("rankme_connect_announcer_version",PLUGIN_VERSION,"RankMe Connect Announcer Version",FCVAR_PLUGIN|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
        
        
    // Update version cvar if needed
        
    new String:sVersionOnCvar[10];
        
        
    GetConVarString(cvarVersion,sVersionOnCvar,sizeof(sVersionOnCvar));
        
        if(!
    StrEqual(PLUGIN_VERSION,sVersionOnCvar))
            
    SetConVarString(cvarVersion,PLUGIN_VERSION,true,true);
            
    }

    public 
    OnAllPluginsLoaded(){

        if(!
    LibraryExists("rankme")){
        
            
    LogError("RankMe not found. Plugin won't work.");
            
        }

    }

    public 
    OnConfigsExecuted(){

        
    g_bAnnounceConnect GetConVarBool(g_cvarAnnounceConnect);
        
    g_bAnnounceConnectCenter GetConVarBool(g_cvarAnnounceConnectCenter);
        
    g_bAnnounceConnectChat GetConVarBool(g_cvarAnnounceConnectChat);
        
    g_bAnnounceConnectHint GetConVarBool(g_cvarAnnounceConnectHint);
        
    g_bAnnounceDisconnect GetConVarBool(g_cvarAnnounceDisconnect);
        
    g_bAnnounceTopConnect GetConVarBool(g_cvarAnnounceTopConnect);
        
    g_AnnounceTopPosConnect GetConVarInt(g_cvarAnnounceTopPosConnect);
        
    g_bAnnounceTopConnectCenter GetConVarBool(g_cvarAnnounceTopConnectCenter);
        
    g_bAnnounceTopConnectChat GetConVarBool(g_cvarAnnounceTopConnectChat);
        
    g_bAnnounceTopConnectHint GetConVarBool(g_cvarAnnounceTopConnectHint);

    }

    public 
    ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[]){
        
        if(
    convar == g_cvarAnnounceConnect)
            
    g_bAnnounceConnect GetConVarBool(g_cvarAnnounceConnect);
            
        else if(
    convar == g_cvarAnnounceConnectCenter)
            
    g_bAnnounceConnectCenter GetConVarBool(g_cvarAnnounceConnectCenter);
            
        else if(
    convar == g_cvarAnnounceConnectChat)
            
    g_bAnnounceConnectChat GetConVarBool(g_cvarAnnounceConnectChat);
            
        else if(
    convar == g_cvarAnnounceConnectHint)
            
    g_bAnnounceConnectHint GetConVarBool(g_cvarAnnounceConnectHint);
            
        else if(
    convar == g_cvarAnnounceDisconnect)
            
    g_bAnnounceDisconnect GetConVarBool(g_cvarAnnounceDisconnect);
            
        else if(
    convar == g_cvarAnnounceTopConnect)
            
    g_bAnnounceTopConnect GetConVarBool(g_cvarAnnounceTopConnect);
            
        else if(
    convar == g_cvarAnnounceTopPosConnect)
            
    g_AnnounceTopPosConnect GetConVarInt(g_cvarAnnounceTopPosConnect);
            
        else if(
    convar == g_cvarAnnounceTopConnectCenter)
            
    g_bAnnounceTopConnectCenter GetConVarBool(g_cvarAnnounceTopConnectCenter);
            
        else if(
    convar == g_cvarAnnounceTopConnectChat)
            
    g_bAnnounceTopConnectChat GetConVarBool(g_cvarAnnounceTopConnectChat);
            
        else if(
    convar == g_cvarAnnounceTopConnectHint)
            
    g_bAnnounceTopConnectHint GetConVarBool(g_cvarAnnounceTopConnectHint);
        
    }

    public 
    OnLibraryAdded(const String:name[])
    {
        if (
    StrEqual(name"rankme"))
        {
        
            
    LogMessage("RankMe Loaded.  Plugin is working.");
            
        }
        
    }

    public 
    OnLibraryRemoved(const String:name[])
    {
        if (
    StrEqual(name"rankme"))
        {
        
            
    LogError("RankMe Unloaded.  Plugin won't work.");
            
        }
        
    }

    public 
    Action:RankMe_OnPlayerLoaded(client){

        if(!
    g_bAnnounceConnect && !g_bAnnounceTopConnect)
            return 
    Plugin_Handled;
        
        
    RankMe_GetRank(client,RankConnectCallback);
        
        return 
    Plugin_Continue;
        
    }

    public 
    RankConnectCallback(clientrankany:data){
        
        
    g_aPointsOnConnect[client] = RankMe_GetPoints(client);
        
        
    g_aRankOnConnect[client] = rank;
            
        new 
    String:sClientName[MAX_NAME_LENGTH];
        
    GetClientName(client,sClientName,sizeof(sClientName));
        
        if(
    g_bAnnounceConnect){
        
            if(
    g_bAnnounceConnectCenter){
                
                
    PrintCenterTextAll("%t","PlayerJoinedCenterHint",sClientName,g_aRankOnConnect[client],g_aPointsOnConnect[client]);
                
            }
            
            if(
    g_bAnnounceConnectChat){
            
                
    CPrintToChatAll("%s %t",MSG,"PlayerJoinedChat",sClientName,g_aRankOnConnect[client],g_aPointsOnConnect[client]);
                
            }
            
            if(
    g_bAnnounceConnectHint){
            
                
    PrintHintTextToAll("%t","PlayerJoinedCenterHint",sClientName,g_aRankOnConnect[client],g_aPointsOnConnect[client]);
                
            }
        
        }
        
        if(
    g_bAnnounceTopConnect && rank <= g_AnnounceTopPosConnect){
        
            if(
    g_bAnnounceTopConnectCenter){
            
                
    PrintCenterTextAll("%t","TopPlayerJoinedCenterHint",g_AnnounceTopPosConnect,sClientName,g_aRankOnConnect[client]);
                
            }
            
            if(
    g_bAnnounceTopConnectChat){
            
                
    CPrintToChatAll("%s %t",MSG,"TopPlayerJoinedChat",g_AnnounceTopPosConnect,sClientName,g_aRankOnConnect[client]);
                
            }
            
            if(
    g_bAnnounceTopConnectHint){
            
                
    PrintHintTextToAll("%t","TopPlayerJoinedCenterHint",g_AnnounceTopPosConnect,sClientName,g_aRankOnConnect[client]);
                
            }
            
        }
        
    }

    public 
    OnClientDisconnect(client){

        if(!
    g_bAnnounceDisconnect)
            return;
            
        new 
    String:sName[MAX_NAME_LENGTH];
        
    GetClientName(client,sName,MAX_NAME_LENGTH);
        
    strcopy(g_sBufferClientName[client],MAX_NAME_LENGTH,sName);
        
        
    g_aPointsOnDisconnect[client] = RankMe_GetPoints(client);
        
    RankMe_GetRank(client,RankDisconnectCallback);
        
    }

    public 
    RankDisconnectCallback(clientrankany:data){
        
        
        if(
    g_bAnnounceDisconnect){
        
            new 
    Position = (rank g_aRankOnConnect[client])*-1;
            new 
    PointsDif g_aPointsOnDisconnect[client]-g_aPointsOnConnect[client];
            
            
    CPrintToChatAll("%s %t",MSG,"PlayerLeft",g_sBufferClientName[client],rank,Position,g_aPointsOnDisconnect[client],PointsDif);
            
        }
            
        return;
        
    }
     
  2. Саша Шеин

    Саша Шеин

    Сообщения:
    1.258
    Симпатии:
    191
    1)
    Замени на:
    PHP:
    if(client&&IsClientInGame(client))
    2)

    Замени на:
    PHP:
    if(client&&IsClientConnected(client))GetClientName(client,sClientName,sizeof(sClientName));
    Замени на:
    PHP:
    if(client&&IsClientConnected(client))GetClientName(client,sName,MAX_NAME_LENGTH);
    P.S. Если только по данным ошибкам править.
     
  3. B1g

    B1g

    Сообщения:
    732
    Симпатии:
    27
    Строки подскажи :)
     
  4. Саша Шеин

    Саша Шеин

    Сообщения:
    1.258
    Симпатии:
    191
    Ctrl+F - вставляй то что надо заменить, нажимаете Enter Думаю далее понятно...
     
  5. B1g

    B1g

    Сообщения:
    732
    Симпатии:
    27
    Все сделал , спасибо, работает.