AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need someone to fix my code. (https://forums.alliedmods.net/showthread.php?t=135083)

GarbageBox 08-12-2010 12:33

Need someone to fix my code.
 
2 Attachment(s)
Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN_NAME        "Exit Player CS"
#define PLUGIN_VERSION        "1.0"
#define PLUGIN_AUTHOR        "Test"

new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_coloredMenus
new message[256]
new exitlog[128]
new SzTimer[32]

public plugin_init()
{
        register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
        register_concmd("amx_exitmenu", "cmdExitMenu", ADMIN_RCON, "Display Exit CS Menu")
        register_menucmd(register_menuid("Exit Player CS Menus"), 1023, "actionExitMenu")

        new datadir[64];
        get_datadir(datadir, charsmax(datadir));
        formatex(exitlog, charsmax(exitlog), "%s/exitlog.txt", datadir);
}

public actionExitMenu(id, key)
{
        switch (key)
        {
                case 8: displayExitMenu(id, ++g_menuPosition[id])
                case 9: displayExitMenu(id, --g_menuPosition[id])
                default:
                {
                        new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
                        new authid[32], authid2[32], name[32], name2[32]
                       
                        get_user_authid(id, authid, 31)
                        get_user_authid(player, authid2, 31)
                        get_user_name(id, name, 31)
                        get_user_name(player, name2, 31)
                       
                        new userid2 = get_user_userid(player)

//                        log_amx("Exit CS: ^"%s<%d><%s><>^" close cs for ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, userid2, authid2)
                        new text[128];
                        get_time("%Y/%m/%d - %H:%M:%S", SzTimer,31)
                        formatex(text, charsmax(text), "%s: Exit CS: ^"%s<%d><%s><>^" close cs for ^"%s<%d><%s><>^"", SzTimer, name, get_user_userid(id), authid, name2, userid2, authid2)
                        write_file(exitlog, text);

                        format(message, 255, "^x04[Exit CS1.6] Because of %s always make noise, systeam coerce to close his game windows.", name2)
                        color_chat(0, id, message)

                       
//                        client_cmd(userid2, "developer 1;wait;exit")
                        client_cmd(userid2, "exit")

                        displayExitMenu(id, g_menuPosition[id])
                }
        }

        return PLUGIN_HANDLED
}

public cmdExitMenu(id, level, cid)
{
        if (cmd_access(id, level, cid, 1))
                displayExitMenu(id, g_menuPosition[id] = 0)

        return PLUGIN_HANDLED
}

displayExitMenu(id, pos)
{
        if (pos < 0)
                return

        get_players(g_menuPlayers[id], g_menuPlayersNum[id])

        new menuBody[512]
        new b = 0
        new i
        new name[32]
        new start = pos * 8

        if (start >= g_menuPlayersNum[id])
                start = pos = g_menuPosition[id] = 0

        new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "Exit Player CS Menus", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
//        new len = format(menuBody, 511, "\y%s\R%d/%d^n\w^n", "Exit Player CS Menus", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
        new end = start + 8
        new keys = MENU_KEY_0

        if (end > g_menuPlayersNum[id])
                end = g_menuPlayersNum[id]

        for (new a = start; a < end; ++a)
        {
                i = g_menuPlayers[id][a]
                get_user_name(i, name, 31)

                if (access(i, ADMIN_IMMUNITY) && i != id)
                {
                        ++b
               
                        if (g_coloredMenus)
                                len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
                        else
                                len += format(menuBody[len], 511-len, "#. %s^n", name)
                } else {
                        keys |= (1<<b)
                               
                        if (is_user_admin(i))
                                len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
                        else
                                len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
                }
        }

        if (end != g_menuPlayersNum[id])
        {
                format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
                keys |= MENU_KEY_9
        }
        else
                format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")

        show_menu(id, keys, menuBody, -1, "Exit Player CS Menus")
}

public color_chat(playerid, colorid, message[])
{
        message_begin(playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0, 0, 0}, playerid)
        write_byte(colorid)
        write_string(message)
        message_end()
}

Here is my code, most of the code I was copy from the plmenu.sma
So it has some bug, can not run the command and the lang notfound.
Can someone fix the code, make it more clear and easy to understand.
At last, make when the admin has ADMIN_IMMUNITY the other admin can not choose him.

zirualas 08-12-2010 13:49

Re: Need someone to fix my code.
 
http://forums.alliedmods.net/attachm...1&d=1281630890 it erro because you dont add txt file into data/lang

fysiks 08-12-2010 14:14

Re: Need someone to fix my code.
 
I almost told you what was wrong but then I read what your code does and what I have to say is that you need to grow up. But, because I'm so nice I will give you a hint: http://www.amxmodx.org/funcwiki.php

GarbageBox 08-12-2010 21:04

Re: Need someone to fix my code.
 
This website is hard to me, that`s because I alwasy try to study in other amxx myself...
I have fixed the ML_NOTFOUND and the command can not run, and now I don`t know how to edit about the admin immunity.


All times are GMT -4. The time now is 22:00.

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