PDA

View Full Version : Need help with script


Dethmaul
10-05-2006, 04:19 AM
Here is a script I am trying to get working: It compiles fine, but when I try to use it ingame it says the command is invalid. If I am right the command to run this plugin should be "amx_pointmenu"
I have racked my brain and cannot figure it out.
Any help would be greatly appreciated


/* Plugin Created by Dethmaul
This plugins is a heavily modified version of admin_aimmenu created by EKS.

Usage:
Bind keys to : amx_pointmenu, amx_lastadminmenu
Aim at desired target and then press the key to bring up the Point Menu
The amx_lastadminmenu basicaly recalls the last targeted player (Allows you to quickly target a player that was kicked -
as long as you haven't selected a new target since kicking the last perpetrator.
This plugins requires the following other plugins to work correctly: dod_eviladmin, amx_forcequit, & spray_management
to work correctly. */

#include <amxmodx>
#include <amxmisc>

/* ******************************* Define section *********************************** */

#define SlapDMG 0 // How much damag the slap command does
#define LastAdminTarget 1 // Include amx_lastadminmenu code
#define MaxPlayers 20 // Max players
#define MaxPlayers 20

/* ******************************* Define section end *********************************** */

new g_AdminTarget[MaxPlayers+1] // Used to store the target, a array is used incase 2+ admins use the menu at the same time.
new g_LastTarget[MaxPlayers+1] // Contains the ID of the last admin target.

public plugin_init()
{
register_plugin("PointMenu","1.0","Dethmaul")
register_menucmd(register_menuid("Point Menu"), 1023, "pointmenu" )
//register_concmd("amx_pointmenu","point_menu",ADMIN_BAN, "Amx_pointmenu Options First..")
register_clcmd("amx_pointmenu","cmdPointMenu",ADMIN_BAN, "Amx_pointmenu Options First..")
#if LastAdminTarget == 1
register_clcmd("amx_lastadminmenu","cmdLastAdminTarget",ADMIN_BAN,"Loads adminmenu based on the last player a admin action was taken agaist")
#endif
}


public pointmenu(id,key){
if (!is_user_connected(g_AdminTarget[id])){
client_print(id,print_center,"This player has left the server")
return PLUGIN_HANDLED
}
new param[2]
switch(key)
{
case 0: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilglow #%d",get_user_userid(g_AdminTarget[id]))
}

case 1: {
user_slap(g_AdminTarget[id],SlapDMG)
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
}

case 2: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_nick #%d DoDUser",get_user_userid(g_AdminTarget[id]))
}

case 3: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilbury #%d",get_user_userid(g_AdminTarget[id]))
}

case 4: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilvision #%d",get_user_userid(g_AdminTarget[id]))
}

case 5: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilmelee #%d",get_user_userid(g_AdminTarget[id]))
}

case 6: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilpimpslap #%d",get_user_userid(g_AdminTarget[id]))
}

case 7: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
client_cmd(id,"SecondPointMenu")
}
}

return PLUGIN_HANDLED
}


public DisplayPointMenu(id)
{

new szMenuBody[512],VictimName[33],len
get_user_name(g_AdminTarget[id],VictimName,32)
new keys
len = format(szMenuBody,2047,"\rPoint Menu^nTarget aquired: %s^n^n",VictimName)
//new len = format( szMenuBody, 255, "\rPoint Menu:^n" )
len += format( szMenuBody[len], 2047-len, "^n\y1. Make Player Glow/Not Glow^n",SlapDMG )
len += format( szMenuBody[len], 2047-len, "^n\y2. Slap Player (%d Damage)^n" )
len += format( szMenuBody[len], 2047-len, "^n\y3. Change Player Name to DoDUser^n" )
len += format( szMenuBody[len], 2047-len, "^n\y4. Bury/Unbury Player^n" )
len += format( szMenuBody[len], 2047-len, "^n\y5. Change Player Vision^n" )
len += format( szMenuBody[len], 2047-len, "^n\y6. Force Melee/Regular^n" )
len += format( szMenuBody[len], 2047-len, "^n\y7. Change Player Run Speed^n" )
len += format( szMenuBody[len], 2047-len, "^n\y8. MegaSlap Player^n" )
len += format( szMenuBody[len], 2047-len, "^n^n\y0. Exit" )

keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
show_menu(id,keys,szMenuBody)
}

public cmdPointMenu(id,level,cid){ // This part of the code gets who the admin is aiming at, and checks for immmunity
if(!cmd_access (id,level,cid,1)) return PLUGIN_HANDLED
new TargetID,body
get_user_aiming(id,TargetID,body)

if (!TargetID){ // Checks to see if "TargetID" has any value, if it does not. Then the admin is not aiming at anyone.
client_print(id,print_center,"No valid target for Adminmenu")
return PLUGIN_HANDLED
}
if (get_user_flags(TargetID) & ADMIN_IMMUNITY){ // Checks if the TargetID has admin immunity
client_print(id,print_center,"Target has admin immunity")
return PLUGIN_HANDLED
}

g_AdminTarget[id] = TargetID

DisplayPointMenu(id)
return PLUGIN_CONTINUE
}
#if LastAdminTarget == 1
public cmdLastAdminTarget(id,level,cid){ // This code checks if g_LastTarget[id] has any value. If it does, it opens the menu menu
if(!cmd_access (id,level,cid,1)) return PLUGIN_HANDLED
if (!g_LastTarget[id]){ // Checks to see if "TargetID" has any value, if it does not. Then the admin is not aiming at anyone.
client_print(id,print_center,"There is no last admin target.")
return PLUGIN_HANDLED
}
g_AdminTarget[id] = g_LastTarget[id]
DisplayPointMenu(id)
return PLUGIN_CONTINUE
}
#endif

Hell Phoenix
10-05-2006, 01:37 PM
Try this for your public cmdPointMenu (I didnt have time to test it...its just what I saw off the top of my head):
public cmdPointMenu(id,level,cid){ // This part of the code gets who the admin is aiming at, and checks for immmunity
if(!cmd_access (id,level,cid,1))
{
return PLUGIN_HANDLED
}

new TargetID,body
get_user_aiming(id,TargetID,body)

if (!TargetID){ // Checks to see if "TargetID" has any value, if it does not. Then the admin is not aiming at anyone.
client_print(id,print_center,"No valid target for Adminmenu")
return PLUGIN_HANDLED
}
if (get_user_flags(TargetID) && ADMIN_IMMUNITY){ // Checks if the TargetID has admin immunity
client_print(id,print_center,"Target has admin immunity")
return PLUGIN_HANDLED
}

g_AdminTarget[id] = TargetID

DisplayPointMenu(id)
return PLUGIN_CONTINUE
}

diamond-optic
10-05-2006, 08:28 PM
also note that when using clcmd... you will always get like invalid or unknown command in the console if you dont have the function return PLUGIN_HANDLED...

Dethmaul
10-05-2006, 10:32 PM
OK. This plugin loads and pulls up the menus, but when I press a key for the actions it doesnt do anything but close the menu.


/* Plugin Created by Dethmaul
This plugins is a heavily modified version of admin_aimmenu.

Usage:
Bind keys to : amx_aimadminmenu, amx_lastadminmenu
Aim at desired target and then press the key to bring up the Point Menu
The amx_lastadminmenu basicaly recalls the last targeted player (Allows you to quickly target a player that was kicked -
as long as you haven't selected a new target since kicking the last perpetrator.
This plugins requires the following other plugins to work correctly: dod_eviladmin, amx_forcequit, & spray_management
to work correctly.
*/

#include <amxmodx>
#include <amxmisc>

/* ******************************* Define section *********************************** */

#define MaxPlayers 20 // Max players
#define BanTime 10 // How long the Temp ban should last
#define LastAdminTarget 1 // Include amx_lastadminmenu code
#define SlapDMG 0 // How much dmg the slap does

// If you want to change the command sent to the client to show the rules search for "amx_publicrules"
/* ******************************* Define section end *********************************** */

new g_AdminTarget[MaxPlayers+1] // Used to store the target, a array is used incase 2+ admins use the menu at the same time.
new g_LastTarget[MaxPlayers+1] // Contains the ID of the last admin target.


public plugin_init() {
register_plugin("AMX Point Mneu","1.0","Dethmaul")
register_menucmd(register_menuid("Aim Adminmenu"),1023,"aimadminmenu")
//register_concmd("amx_pointmenu", "cmdPointMenu", ADMIN_LEVEL_B, "Amx_pointmenu Options First..")
register_clcmd("amx_aimadminmenu","cmdAimAdminmenu",ADMIN_BAN,"Loads adminmenu based on who your aiming at")
#if LastAdminTarget == 1
register_clcmd("amx_lastadminmenu","cmdLastAdminTarget",ADMIN_BAN,"Loads adminmenu based on the last player a admin action was taken agaist")
#endif
}

public aimadminmenu(id,key){
if (!is_user_connected(g_AdminTarget[id])){
client_print(id,print_center,"This player has left the server")
return PLUGIN_HANDLED
}
new param[2]
switch(key){
case 0: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilglow #%d",get_user_userid(g_AdminTarget[id]))
}

case 1: {
user_slap(g_AdminTarget[id],SlapDMG)
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
}

case 2: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_nick #%d DoDUser",get_user_userid(g_AdminTarget[id]))
}

case 3: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilbury #%d",get_user_userid(g_AdminTarget[id]))
}

case 4: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilvision #%d",get_user_userid(g_AdminTarget[id]))
}

case 5: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilmelee #%d",get_user_userid(g_AdminTarget[id]))
}

case 6: {
g_LastTarget[id] = g_AdminTarget[id]
//param[0] = 0
param[0] = g_AdminTarget[id]
param[1] = id
//EchoAdminAction(param)
server_cmd("amx_evilpimpslap #%d",get_user_userid(g_AdminTarget[id]))
}

}
return PLUGIN_HANDLED
}

public DisplayAimAdminmenu(id){
new menuBody[512],VictimName[33],len
get_user_name(g_AdminTarget[id],VictimName,32)

len = format(menuBody,2047,"\rPoint Menu^nTarget aquired: %s^n^n",VictimName)
len += format(menuBody[len],2047 - len,"\w1. Make Player Glow/Not Glow^n" )
len += format(menuBody[len],2047 - len,"\w2. Slap Player (%d Damage)^n",SlapDMG )
len += format(menuBody[len],2047 - len,"\w3. Change Player Name to DoDUser^n" )
len += format(menuBody[len],2047 - len,"\w4. Bury/Unbury Player^n" )
len += format(menuBody[len],2047 - len,"\w5. Change Player Vision^n" )
len += format(menuBody[len],2047 - len,"\w6. Force Melee/Regular^n" )
len += format(menuBody[len],2047 - len,"\w7. Change Player Run Speed^n" )
len += format(menuBody[len],2047 - len,"\w8. MegaSlap Player^n^n^n" )
len += format(menuBody[len],2047 - len,"\w0. Exit" )

new keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
show_menu(id,keys,menuBody)
}
public cmdAimAdminmenu(id,level,cid){ // This part of the code gets who the admin is aiming at, and checks for immmunity
if(!cmd_access (id,level,cid,1))
{
return PLUGIN_HANDLED
}
new TargetID,body
get_user_aiming(id,TargetID,body)

if (!TargetID){ // Checks to see if "TargetID" has any value, if it does not. Then the admin is not aiming at anyone.
client_print(id,print_center,"No valid target for Adminmenu")
return PLUGIN_HANDLED
}
if(access(TargetID, ADMIN_IMMUNITY)) {
//if (get_user_flags(TargetID) && ADMIN_IMMUNITY){ // Checks if the TargetID has admin immunity
client_print(id,print_center,"Target has admin immunity")
return PLUGIN_HANDLED
}

g_AdminTarget[id] = TargetID

DisplayAimAdminmenu(id)
return PLUGIN_HANDLED
}

#if LastAdminTarget == 1
public cmdLastAdminTarget(id,level,cid){ // This code checks if g_LastTarget[id] has any value. If it does, it opens the menu menu
if(!cmd_access (id,level,cid,1)) return PLUGIN_HANDLED
if (!g_LastTarget[id]){ // Checks to see if "TargetID" has any value, if it does not. Then the admin is not aiming at anyone.
client_print(id,print_center,"There is no last admin target.")
return PLUGIN_HANDLED
}
g_AdminTarget[id] = g_LastTarget[id]
DisplayAimAdminmenu(id)
return PLUGIN_HANDLED
}
#endif

diamond-optic
10-05-2006, 11:46 PM
from now on use code tags so that it keeps its formatting..

diamond-optic
10-06-2006, 12:00 AM
do this to line 130:
change
show_menu(id,keys,menuBody) to
show_menu(id,keys,menuBody, -1, "Aim Adminmenu")
now i get msgs like:

Unknown command: amx_evilvision
Unknown command: amx_evilmelee
which is just becuase i dont have those commands so it should work for you..

Dethmaul
10-06-2006, 03:03 AM
Thamks for all you help.. Got it working. Turns out my register menuid command was invalid

Dethmaul
10-19-2006, 08:08 PM
Ok so I changed my plugin to have more menu pages. Everything is working except my options to go back a menu page. i can go forward to next menu but when I hit the option to go back a menu it just closes the menu like an invalid key is pressed. I meesed with the key parameters... removing one key and then on my second menu I could get it to go back to first menu but the key was 9 instead of 0 and the third menu still continued to close the menu completely



Here is the plugin, I cannot seem to get it to copy correctly here
http://forums.alliedmods.net/showthread.php?t=46131