AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Admin powers (https://forums.alliedmods.net/showthread.php?t=106005)

rikards1 10-10-2009 16:03

Admin powers
 
Hello, just wonder..... why do I get a lot of errors of this? (made a godmode and noclip plugin of blockmaker :P)

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <cstrike>
#include <fakemeta>
#define PLUGIN "admin_power"
#define VERSION "1.0"
#define AUTHOR "Rikards1"
#define BM_ADMIN_LEVEL ADMIN_MENU //admin access level to use this plugin. ADMIN_MENU = flag 'u'
// global booleans
new bool:gbAdminGodmode[33];
new 
bool:gbAdminNoclip[33];
/***** PLUGIN START *****/
public plugin_init()
{
register_plugin(PLUGINVERSIONAUTHOR);
register_cvar(PLUGINVERSIONFCVAR_SERVER0.0);
 
//register client commands
register_clcmd("say /ap""showMainMenu");
 
//register forwards
register_forward(FM_EmitSound"forward_EmitSound");
register_menucmd(register_menuid("bmMainMenu"), gKeysMainMenu"handleMainMenu");
 
//register events
register_event("DeathMsg""eventPlayerDeath""a");
register_event("TextMsg""eventRoundRestart""a""2&#Game_C""2&#Game_w");
register_event("ResetHUD""eventPlayerSpawn""b");
register_event("CurWeapon""eventCurWeapon""be");
register_logevent("eventRoundRestart"2"1=Round_Start");
 
//make save folder in basedir (new saving/loading method)
new szDir[64];
new 
szMap[32];
get_basedir(szDir64);
add(szDir64"/blockmaker");
 
//make config folder if it doesn't already exist
if (!dir_exists(szDir))
{
mkdir(szDir);
}
 
get_mapname(szMap32);
formatex(gszNewFile96"%s/%s.bm"szDirszMap);
}
//creat main menu
new size sizeof(gszMainMenu);
add(gszMainMenusize"\yAdmin Power^n^n");
add(gszMainMenusize"\r1. %sNoclip: %s^n");
add(gszMainMenusize"\r2. %sGodmode: %s^n^n^n");
add(gszMainMenusize"\r0. \wClose");
gKeysMainMenu B1 B2 B0;
/***** FORWARDS *****/
public client_connect(id)
{
//player doesn't have godmode or noclip
gbAdminGodmode[id] = false;
gbAdminNoclip[id] = false;
}
public 
client_disconnect(id)
{
}
/***** EVENTS *****/
public eventPlayerDeath()
{
new 
id read_data(2);
}
public 
eventRoundRestart()
{
//iterate through all players
for (new id 1id <= 32; ++id)
{
//reset all players timers
resetTimers(id);
}
}
public 
eventPlayrSpawn(id)
{
//if player has godmode enabled
if (gbAdminGodmode[id])
{
//re-enable godmode on player
set_user_godmode(id1);
}
 
//if player has noclip enabled
if (gbAdminNoclip[id])
{
//re-enable noclip on player
set_user_noclip(id1);
}
}
/* MENUS */
public showMainMenu(id)
{
new 
col[3];
new 
szMenu[256];
new 
szGodmode[6];
new 
szNoclip[6];
col = (get_user_flags(id) & BM_ADMIN_LEVEL "\w" "\d");
szNoclip = (get_user_noclip(id) ? "\yOn" "\rOff");
szGodmode = (get_user_godmode(id) ? "\yOn" "\rOff");
 
//format the main menu
format(szMenu256gszMainMenucolszNoclipcolszGodmode);
 
//show the main menu to the player
show_menu(idgKeysMainMenuszMenu, -1"bmMainMenu");
 
return 
PLUGIN_HANDLED;
}
showBlockMenu(id)
{
new 
col[3];
new 
szMenu[256];
new 
szGodmode[6];
new 
szNoclip[6];
new 
szSize[8];
col = (get_user_flags(id) & BM_ADMIN_LEVEL "\w" "\d");
szNoclip = (get_user_noclip(id) ? "\yOn" "\rOff");
szGodmode = (get_user_godmode(id) ? "\yOn" "\rOff");
 
//format the main menu
format(szMenu256gszBlockMenugszBlockNames[gSelectedBlockType[id]], colcolcolcolcolszNoclipcolszGodmode);
 
//show the block menu to the player
show_menu(idgKeysBlockMenuszMenu, -1"bmBlockMenu");
 
return 
PLUGIN_HANDLED;
}
public 
handleMainMenu(idnum)
{
switch (
num)
{
case 
N1: { toggleNoclip(id); }
case 
N2: { toggleGodmode(id); }
case 
N0: { return; }
}
 
}
toggleGodmode(id)
{
//make sure player has access to this command
if (get_user_flags(id) & BM_ADMIN_LEVEL)
{
//if player has godmode
if (get_user_godmode(id))
{
//turn off godmode for player
set_user_godmode(id0);
gbAdminGodmode[id] = false;
}
else
{
//turn on godmode for player
set_user_godmode(id1);
gbAdminGodmode[id] = true;
}
}
}
toggleNoclip(id)
{
//make sure player has access to this command
if (get_user_flags(id) & BM_ADMIN_LEVEL)
{
//if player has noclip
if (get_user_noclip(id))
{
//turn off noclip for player
set_user_noclip(id0);
gbAdminNoclip[id] = false;
}
else
{
//turn on noclip for player
set_user_noclip(id1);
gbAdminNoclip[id] = true;
}
}


There u have the php....
And I´ve tested compile it, get like 5 errors...... but I think thats pretty few, couse its my first plugin ^^

Alucard^ 10-10-2009 17:31

Re: Admin powers
 
Why you don't test it?

Also, use [php] bbcodes, becouse is hard to read in the [code] bbcode.

Oh, and you have to indent your code.

vitorrd 10-10-2009 17:43

Re: Admin powers
 
Quote:

Originally Posted by Alucard^ (Post 957957)
Why you don't test it?

Also, use [php] bbcodes, becouse is hard to read in the [code] bbcode.

Oh, and you have to indent your code.

If I'm not wrong the [quote] tag unindents the code.

OneMoreLevel 10-10-2009 18:13

Re: Admin powers
 
^ He is right.

You need to use [PHP] Tags and we'll help you.

Arkshine 10-10-2009 18:17

Re: Admin powers
 
or [small] or [pawn] , but recommend to use [php] for long code.


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

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