| closedadminmsg |
| Started by bof on 07-25-2008, 01:17 PM |
Threads: 2
Joined: Jun 2006
Hi all,rnrni made my firts plugin this day, but the compilation failed.rnit's a small plugin, who should show a menu. the menu comes from a file, and allow admin to show typical message on hud.rnrn#include <amxmodx>rn#include <amxmisc>rnrn#define MAX_LIGNES 21rnrnnew position[33]rnnew nblignernnew textemenu[1024]rnnew texteaafficher[MAX_LIGNES][128]rnnew messages_ini_file[64]rnnew pos2rnrnpublic plugin_init()rn{rn new i= 0rn register_plugin("Admin Chat menu", "v1.0", "Bof")rn register_menucmd(register_menuid("admins messages"), 1023, "actionmenu")rn register_clcmd("amx_admintchatmenu", "msgmenu", ADMIN_MENU, "-montre les commandes de texte admin")rn rn get_configsdir(messages_ini_file, 63);rn format(messages_ini_file, 63, "%s/maps.ini", messages_ini_file);rn rn if(file_exists(messages_ini_file))rn {rn nbligne =file_size(messages_ini_file, 1)rn }rn elsern {rn nbligne = 0rn }rn while(i< nbligne)rn {rn read_file(messages_ini_file, i, 127, texteaafficher[i])rn i++rn }rn}rnrnpublic msgmenu(id, level, cid)rn{rn if (!cmd_access(id, level, cid, 1))rn return PLUGIN_HANDLEDrn position[id] = 0rn menudisplay(position[id], id)rn return PLUGIN_HANDLED rn}rnrnpublic actionmenu(id, key)rn{rn new pos1 = position[id] * 7 + key -1rn switch(key)rn {rn case 8:rn {rn if(position[id] > 1)rn position[id]--rn }rn case 9:rn {rn if(position[id] < (MAX_LIGNES %7))rn position[id]++rn }rn case 0:rn return PLUGIN_HANDLEDrn default:rn {rn set_hudmessage(200, 0, 0)rn show_hudmessage(0, texteaafficher[pos1])rn }rn }rn menudisplay(position[id], id)rn return PLUGIN_HANDLEDrn}rnrnpublic menudisplay(pos2, id)rn{rn pos2 = position[id]*7rn format(textemenu, 1023, "Quel message?^n1. %s^n2. %s^n3. %s^n4. %s^n5. %s^n6. %s^n7. %s^n^n8. page prec^n9. page suiv^n0. quitter", texteaafficher[pos2], texteaafficher[pos2+1], texteaafficher[pos2+2], texteaafficher[pos2+3], texteaafficher[pos2+4], texteaafficher[pos2+5], texteaafficher[pos2+6])rn show_menu(id, 1023, textemenu)rn}rnrnthe current eror is "argument mismatch" or input line too longrn(on the plugin_init part...)rnI doesn't understand many things in amx scripting, and i hope find a solution here.rnrnps: I am belgian, and english is not easy for me, and yes i seek too a solution by myself.
Threads: 2
Joined: Jun 2006
ok, i hav ecorrect some eror.rnrnread_file ==> read_file(messages_ini_file, i, texteaafficher[i], 127, a)rnnew keys = MENU_KEY_0|...9 for register_menucmdrnand some other small erors.rnrnNow the plugin is compiled and work. (just one warning: pos2 is never used)rnrnwhen I test ingame, the amx command show the menu correctly, but I cannot move into the menu, and press anykey close the menu.rn:/
Threads: 2
Joined: Jun 2006
Ok Ok, after many try, I have resolved all problems. You can close this topic.

