AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with assigning values. (https://forums.alliedmods.net/showthread.php?t=5350)

twistedeuphoria 08-29-2004 15:41

Need help with assigning values.
 
I'm trying to write a plugin so you can say /afk and you join spectators but it keeps your team and model so when you type /back you join the team you were on with the same model. Maybe my mistake is obvious but I can't get the plugin to choose the right team. I also need help with the get model and set model commands. This is the code I have so far.
Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public plugin_init()
{
  register_plugin("AFK and Back","0.1","twistedeuphoria")
  register_clcmd("say","say_event")
  return PLUGIN_CONTINUE
}
 

public say_event(id)
{
 
    new sid[2]
    new team[32]   
    new model[32]
    sid[0] = id
    num_to_str(id,sid,2)
    new said[192]
    read_args(said,191)
    new name[32]
    get_user_name(id,name,31)
    if(containi(said,"/afk") != -1)
    {
      if (is_user_alive(id))
      {
        cs_get_user_model(id,model[id],4)//How do I use this?
        team[id] = get_user_team(id)
        user_kill(id)
        client_print(0,print_chat,"*DEAD* %s : I'll be back...",name)
        client_cmd(id,"jointeam 6")   
      } 
 
  }
  if(containi(said,"/back") != -1)
  {
     
    client_print(0,print_chat,"%s : I'm back....",name)
    if(team[id] == 1)
        client_cmd(id,"jointeam 1")   
    else
        client_cmd(id,"jointeam 2")
    cs_set_user_model(id,model[id])//Need help here too.
  } 
}

Thank you for your time.

Votorx 08-29-2004 17:05

Change length to 32.

twistedeuphoria 08-29-2004 17:07

On what the get_user_name?

Votorx 08-29-2004 17:09

No, cs_get_user_model.

twistedeuphoria 08-29-2004 23:21

Well I changed that...let me clarify what is happening. Someone will type /afk as a CT then some time later type /back and they will join the CT side. But, if a T says /afk then /back they will join the CT side.

KRoT@L 08-29-2004 23:38

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> new afk_team[32] new afk_model[32][32] public plugin_init() {     register_plugin("AFK and Back","0.1","twistedeuphoria")     register_clcmd("say","say_event")     return PLUGIN_CONTINUE } public say_event(id) {   new said[192] read_args(said,191) new name[32] get_user_name(id,name,31) if(containi(said,"afk") != -1) {     if (is_user_alive(id))     {         cs_get_user_model(id,afk_model[id],31)         afk_team[id] = get_user_team(id)         user_kill(id,1)         client_print(0,print_chat,"*DEAD* %s : I'll be back...",name)         client_cmd(id,"jointeam 6")     } } else if(containi(said,"back") != -1) {     client_print(0,print_chat,"%s : I'm back...",name)     if(afk_team[id] == 1)         client_cmd(id,"jointeam 1")     else         client_cmd(id,"jointeam 2")     client_cmd(id,"wait")     client_cmd(id,"slot5")     cs_set_user_model(id,afk_model[id]) } return PLUGIN_CONTINUE }

twistedeuphoria 08-30-2004 01:03

Thank you very much! :D But, it wont "slot 5", is there not enough wait time or what?

KRoT@L 08-30-2004 01:38

I tried on my computer and slot5 was executed, but if it doesn't work with you, just add some more
Code:
client_cmd(id,"wait")
until it works ;)

twistedeuphoria 08-30-2004 13:05

My computer hates me :( . I put 50 of them and it still doesn't work. =_= Something else maybe?

Could you post your .amx and .sma that worked?

KRoT@L 08-30-2004 13:51

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> new afk_team[32] new afk_model[32][32] public plugin_init() {     register_plugin("AFK and Back","0.1","twistedeuphoria")     register_clcmd("say","say_event")     return PLUGIN_CONTINUE } public say_event(id) {   new said[192] read_args(said,191) new name[32] get_user_name(id,name,31) if(containi(said,"afk") != -1) {     if (is_user_alive(id))     {         cs_get_user_model(id,afk_model[id],31)         afk_team[id] = get_user_team(id)         user_kill(id,1)         client_print(0,print_chat,"*DEAD* %s : I'll be back...",name)         client_cmd(id,"jointeam 6")     } } else if(containi(said,"back") != -1) {     client_print(0,print_chat,"%s : I'm back...",name)     new playerVGUI[2]     get_user_info(id,"_vgui_menus",playerVGUI,1)     if (playerVGUI[0] != '0')     {         set_user_info(id,"_vgui_menus","0")         client_cmd(id,"wait")         client_cmd(id,"wait")         client_cmd(id,"wait")         client_cmd(id,"wait")         if(afk_team[id] == 1)             client_cmd(id,"jointeam 1")         else             client_cmd(id,"jointeam 2")         client_cmd(id,"wait")         client_cmd(id,"wait")         client_cmd(id,"wait")         client_cmd(id,"wait")         client_cmd(id,"slot5")         set_task(2.0, "set_vgui", id)     }     else     {         if(afk_team[id] == 1)             client_cmd(id,"jointeam 1")         else             client_cmd(id,"jointeam 2")         client_cmd(id,"wait")         client_cmd(id,"wait")         client_cmd(id,"slot5")     }     cs_set_user_model(id,afk_model[id]) } return PLUGIN_CONTINUE } public set_vgui(id) {     set_user_info(id,"_vgui_menus","1") }


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

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