AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   plugins help (https://forums.alliedmods.net/showthread.php?t=2461)

Nick 06-05-2004 22:45

plugins help
 
I tryed my best to make this plugin better but Im sure its pretty messed up, it works I think, but Im sure there is a much better way for doing it.
Code:
#include <amxmodx>    #include <amxmisc>    #include <fun>        new g_ForceRulesCount[32]        public plugin_init() {    register_plugin("ForceRules","1.1","Nick")    register_concmd("amx_forcerules","ForceRules",ADMIN_SLAY,"<nick or steamid>")    return PLUGIN_CONTINUE       }        public plugin_precache()           {           precache_sound("misc/tslap.wav")           }          public client_connect(id) {    g_ForceRulesCount[id] = 0 }    public ForceRules(id,level,cid) {    if (!cmd_access(id,level,cid,2)) {         return PLUGIN_HANDLED         }    switch (++g_ForceRulesCount[id])    { // 1st Punishment - Makes player glow pink //======================================================================           case 1: {    new arg[32]    read_argv(1,arg,31)    new player = cmd_target(id,arg,0)    if (!player)    return PLUGIN_HANDLED    new authid[16],name2[32],authid2[16],name[32]    get_user_authid(id,authid,15)    get_user_name(id,name,31)    get_user_authid(player,authid2,15)    get_user_name(player,name2,31)    set_user_rendering(player, kRenderFxGlowShell, 255, 0, 255, kRenderTransAlpha, 255)    show_motd(player,"/addons/amxx/custom/forcerules.txt","Follow these rules!")        client_cmd(0,"spk barney/ba_dontmake")    set_hudmessage(255, 0, 0, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2);    show_hudmessage(0,"%s has been warned 1/5 times",name)    client_print(0,print_chat,"[AMXX] 1st warning...Now glow pink")    return PLUGIN_HANDLED }       // 2nd Punishment - Slaps player with 99 damage //======================================================================= case 2: {    new arg[32]    read_argv(1,arg,31)    new player = cmd_target(id,arg,0)    if (!player)    return PLUGIN_HANDLED      user_slap(player,99)    show_motd(player,"/addons/amxx/custom/forcerules.txt","Follow these rules!")    new authid[16],name2[32],authid2[16],name[32]    get_user_authid(id,authid,15)    get_user_name(id,name,31)    get_user_authid(player,authid2,15)    get_user_name(player,name2,31)      log_to_file("addons/amxx/custom/forcerules.log","Cmd: ^"%s<%d><%s><>^" (ForceRules) ^"%s<%d><%s><>^"",    name,get_user_userid(id),authid, name2,get_user_userid(player),authid2)        client_cmd(0,"spk misc/tslap.wav")    set_hudmessage(255, 0, 0, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2);    show_hudmessage(0,"%s has been warned 2/5 times",name)    client_print(0,print_chat,"[AMXX] 2nd warning...slapped with 99 damage")    return PLUGIN_HANDLED }   // 3rd Punishment - Slays player //========================================================================    case 3: {    new arg[32]    read_argv(1,arg,31)    new player = cmd_target(id,arg,0)    if (!player)    return PLUGIN_HANDLED      user_kill(player)    show_motd(player,"/addons/amxx/custom/forcerules.txt","Follow these rules!")    new authid[16],name2[32],authid2[16],name[32]    get_user_authid(id,authid,15)    get_user_name(id,name,31)    get_user_authid(player,authid2,15)    get_user_name(player,name2,31)    log_to_file("addons/amxx/custom/forcerules.log","Cmd: ^"%s<%d><%s><>^" (ForceRules) ^"%s<%d><%s><>^"",    name,get_user_userid(id),authid, name2,get_user_userid(player),authid2)        client_cmd(0, "spk ^"warning we have a ass hole^"")    set_hudmessage(255, 0, 0, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2);    show_hudmessage(0,"%s WARNING 3/5, last chance",name)    client_print(0,print_chat,"[AMXX] 3rd warning...now being slayed")    return PLUGIN_HANDLED } // 4th Punishment - Starts vote to kick player //=========================================================================      case 4: {    new arg[32]    read_argv(1,arg,31)    new player = cmd_target(id,arg,0)    if (!player)    new Kickname[32]    get_user_name(player,Kickname,32)    client_cmd(0,"spk barney/ba_endline")    set_hudmessage(255, 0, 0, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2);    show_hudmessage(0,"Voting has started to kick")    client_print(0,print_chat,"[AMXX] %s WARNED 4/5 times, voting has started")    server_cmd("amx_votekick %s",Kickname)    return PLUGIN_HANDLED    } // 5th Punishment - Kicks player //=========================================================================          case 5: {      new arg[32]    read_argv(1,arg,0)    new player = cmd_target(id,arg,0)    if (!player)    new Kickname[32]    get_user_name(player,Kickname,32)    set_hudmessage(255, 0, 0, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2);    show_hudmessage(0,"%s 5/5 now being kicked.")    client_print(0,print_chat,"[AMXX] %s WARNED 5/5 times, voting has started")    server_cmd("amx_kick %s",Kickname)    return PLUGIN_HANDLED   }  } }
I get these errors
Code:

amx_forcerules.sma<179> : warning 209: function "ForceRules" should have a return value
And I also get a run time error on line 176, I don't know why either.

Jinto 06-05-2004 22:52

at the end of it add
Code:

return PLUGIN_HANDLED
Basically at the end you don't have it so thats what its looking for.. You have it in your case statments but the compiler doesn't see those it looks at the end of the function for one.

Nick 06-05-2004 23:52

Ok so you want me to add the at the very end?

Nick 06-06-2004 20:42

n e one know?

T(+)rget 06-06-2004 22:33

Like this Jinto means:
Code:

case 5:
{   
  new arg[32]
  read_argv(1,arg,0)
  new player = cmd_target(id,arg,0)
  if (!player)
  new Kickname[32]
  get_user_name(player,Kickname,32)
  set_hudmessage(255, 0, 0, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2);
  show_hudmessage(0,"%s 5/5 now being kicked.")
  client_print(0,print_chat,"[AMXX] %s WARNED 5/5 times, voting has started")
  server_cmd("amx_kick %s",Kickname)
  return PLUGIN_HANDLED
  }
}
return PLUGIN_HANDLED
}

Why you got that error is because you are returning in subsections of your function, if you do this you need to return at the end of your function.

Nick 06-07-2004 00:01

Thanks fixed it :)


All times are GMT -4. The time now is 14:46.

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