AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help getting server initiate commands on players (https://forums.alliedmods.net/showthread.php?t=168373)

Jenkins 09-28-2011 04:39

Help getting server initiate commands on players
 
Okay, I got a little menu where you can choose the slay player, everything works fine except to the slaying where nothing happens. Its exactly the same with ban too. I will give you my execute handle in the menu.

Slay handle:
Code:

public HandleSlay(id, menu, item)
{
        if(item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }
       
        new data[6], name[64]
        new access, callback
       
        menu_item_getinfo (menu, item, access, data, 5, name, 63, callback)
        new szSlayHim = str_to_num ( data )
       
        new szName[33]
        get_user_name(id, szName, 32)
        get_user_name(szSlayHim, szPlayerName, 32)
        get_user_authid(szSlayHim, authid, 31)
       
        ColorChat(0, GREY, "%s ^4%s^3 has slayed ^4%s^3!", prefix, szName, szPlayerName)
        server_cmd("amx_slay %s", szPlayerName)

       
        return PLUGIN_CONTINUE
}

Ban handle:
Code:

public HandleBan(id, menu, item)
{
        if(item == MENU_EXIT)
        {
                menu_destroy(menu)
                return PLUGIN_HANDLED
        }
       
        new data[6], name[64]
        new access, callback
       
        menu_item_getinfo (menu, item, access, data, 5, name, 63, callback)
        new szBanHim = str_to_num ( data )
       
        new szName[33]
        get_user_name(id, szName, 32)
        get_user_name(szBanHim, szPlayerName, 32)
        get_user_authid(szBanHim, authid, 31)
       
        ColorChat(0, GREY, "%s ^4%s^3 has banned ^4%s^3! ^4(30 min)^3", prefix, szName, szPlayerName)
        server_cmd("amx_ban ^"30^" ^"%s^" ^"Breaking a rule^"", authid)

       
        return PLUGIN_CONTINUE
}


fysiks 09-28-2011 18:15

Re: Help getting server initiate commands on players
 
You need to find out the exact command that is being sent to the server AFTER the name gets formatted in there. If that isn't incorrect then try:

server_cmd("amx_slay #%d", get_user_userid(szSlayHim))

Also, try to avoid using the "sz" prefix on non-string variables as "sz" denotes a string and makes your code less readable if used incorrectly.

Jenkins 09-29-2011 06:37

Re: Help getting server initiate commands on players
 
What about ban?
I saw your correction on the slaycode and ima send it home since im in school but please tell me the ban correction :p

fysiks 09-29-2011 21:55

Re: Help getting server initiate commands on players
 
Change amx_slay to amx_ban . . . .


All times are GMT -4. The time now is 19:39.

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