3 posts,
3 people · 1,036 views
Thread Rating: ★★★★★
| closedCan't read Variable[id] on PTeam event |
| Started by danniboy90 on 10-10-2011, 01:07 PM |
D
danniboy90
Threads: 1
Joined: Oct 2011
started this thread
Posts: 2Threads: 1
Joined: Oct 2011
10-10-2011, 01:07 PM
#1
Hi,rnrnI'm trying to bring up a menu if a player hasn't accepted the rules.rnrnA menu will show upon death, spawn or teamjoin/change if accepted[id] isrnfalse.rnrnHowever, when a player chooses a team it doesn't remember if yournaccepted or not, but when you die or spawn it remembers.rnrnI find it strange, since it's the same function that checks if the playerrnaccepted or not.rnrnI really hope someone can help me figure this out, and thank you in advance ;)rnrnCode:rn
rn// Menu will show upon "death", "spawn" and "team join" if the player hasn't acceptedrnrn#include <amxmodx>rn#include <amxmisc>rn#include <hamsandwich>rnrn#define PLUGIN "Rules"rn#define VERSION "1.0"rn#define AUTHOR "me"rn#define KeysRules (1<<5)|(1<<6)|(1<<7) // Keys: 678rnrnrn/* For keeping track of people! */rnnew name[33][32];rnnew authid[33][32];rnnew bool:accepted[33];rnrnrnpublic plugin_init()rn{rn register_plugin(PLUGIN, VERSION, AUTHOR);rn rn /* Menu Rules */rn register_menucmd(register_menuid("Rules"), KeysRules, "PressedRules");rn register_clcmd("say /rules", "ShowRules", ADMIN_ALL, "Shows The menu");rn /* Menu End */rn rn RegisterHam(Ham_Spawn,"player","checkforRulesAccepted", 1);rn RegisterHam(Ham_Killed, "player", "checkforRulesAccepted", 1);rn register_event("PTeam","checkforRulesAccepted","a");rn}rnrn////////////////////////////////////////////////////////////////////////////////////////////////////rnrnpublic checkforRulesAccepted(id)rn{rn //if(!get_pcvar_num(p_enable) || is_bot[id] == 1)rn //return HAM_IGNOREDrn rn if (accepted[id])rn return PLUGIN_CONTINUE;rn rn client_print(id, print_chat, "Rules not accepted. Opening Menu");rn ShowRules(id);rn rn return PLUGIN_CONTINUE;rn}rnrn////////////////////////////////////////////////////////////////////////////////////////////////////rnrnpublic client_putinserver(id)rn{rn get_client_info(id);rn}rnrn////////////////////////////////////////////////////////////////////////////////////////////////////rnrnpublic get_client_info(id)rn{rn get_user_name(id,name[id],31)rn get_user_authid(id,authid[id],31)rn accepted[id] = false;rn}rnrnrnrn/* Menu Rules */rnrnpublic ShowRules(id)rn{rn show_menu(id, KeysRules, "
6. wAccept^n
7. wDeny^n^n
8. wShow Rules^n", -1, "Rules") // Display menurn}rnrnpublic PressedRules(id, key) {rn /* Menu:rn * 6. Acceptrn * 7. Denyrn * 8. Show Rulesrn */rnrn switch (key)rn {rn case 5:rn { // 6rn client_print(id, print_chat, "Accepted");rn accepted[id] = true;rn }rn case 6:rn { // 7rn client_print(id, print_chat, "Denied");rn accepted[id] = false;rn }rn case 7:rn { // 8rn client_print(id, print_chat, "!RULES HUD!");rn ShowRules(id);rn }rn }rn return PLUGIN_CONTINUE;rn}rnrn/* End Menu Rules End */rnposted here
Posts: 776Threads: 75
Joined: Nov 2007
10-11-2011, 02:12 PM
#2
its a VERY long time since i did any coding. does this fit your needs maybernrnrn
#include <amxmodx>rn#include <amxmisc>rn#include <dodx>rnrn#define PLUGIN "New Plug-In"rn#define VERSION "1.0"rn#define AUTHOR "VFR"rnrnnew accepted[33]rnrnpublic plugin_init() {rn register_plugin(PLUGIN, VERSION, AUTHOR)rn rn // Add your code here...rn}rnrnpublic dod_client_changeclass(id)rn checkforRulesAccepted(id)rn rnpublic dod_client_changeteam(id)rn checkforRulesAccepted(id)rnrnpublic checkforRulesAccepted(id) rn{ rn //if(!get_pcvar_num(p_enable) || is_bot[id] == 1) rn //return HAM_IGNORED rn rn if (accepted[id]) rn return PLUGIN_CONTINUErn rn client_print(id, print_chat, "Rules not accepted. Opening Menu")rn rn //ShowRules(id)rn rn return PLUGIN_CONTINUE rn}posted here
Posts: 229Threads: 24
Joined: Oct 2006
10-12-2011, 10:48 PM
#3
PTeam is a message, not an event.

