Raised This Month: $51 Target: $400
 12% 

Storing and Moving via Global Var


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 07-07-2012 , 08:44   Storing and Moving via Global Var
Reply With Quote #1

Here's the Code:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Epic"

new StoredP

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /store""Store")
    
register_clcmd("say /move""Move")
}

public 
Store(id)
{
    static 
Players[32], Pnum;
    
get_players(PlayersPnum"ae""TERRORIST")
    
    for(new 
0Pnumi++)
    {
        
StoredP Players[i]
        
cs_set_user_team(StoredPCS_TEAM_CT)
        
client_print(StoredPprint_chat"[AMXX] T's stored")
    }
}

public 
Move(id)
{
    if(
is_user_connected(StoredP))
    {
        
cs_set_user_team(StoredPCS_TEAM_T)
    }

Quote:
Trying to do:

Store all the terrorist in the global var and move them to CT and then move them back to T.
Quote:
Whats Happening:

Store's all the terrorists in the global var and moves them all to CT and only moves the last terrorist stored back to T.
Do i have to use a 2d array for this?

any help would be appreciated

Last edited by EpicMonkey; 07-07-2012 at 08:47.
EpicMonkey is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 07-07-2012 , 08:48   Re: Storing and Moving via Global Var
Reply With Quote #2

You'd have to loop through the players again.
__________________
Hi.
Kreation is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-07-2012 , 08:48   Re: Storing and Moving via Global Var
Reply With Quote #3

You must us an array
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-07-2012 , 09:26   Re: Storing and Moving via Global Var
Reply With Quote #4

Store :

get_players(g_GlobalPlayersArray


And loop in Move function
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 07-07-2012 , 11:11   Re: Storing and Moving via Global Var
Reply With Quote #5

k , thank you
EpicMonkey is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 08-27-2012 , 04:30   Re: Storing and Moving via Global Var
Reply With Quote #6

Ive tried something similar like this

PHP Code:
#include <amxmodx>
#include <fun>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "EpicMonkey"

new g_Test[32];

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("CurWeapon""current_weapon""be""1=1")
}

public 
current_weapon(id
{
    if(
g_Test[id])
    {
        
engclient_cmd(g_Test[id], "weapon_knife");
    }
}

public 
Test(id)
{
    new 
pnumi;
    
get_players(g_Testpnum"ae""TERRORIST")
    
    for(
0pnumi++)
    {
        
StripandHealth(g_Test[i])
    }

if a Test player gets another weapon or switches to another weapon, it doesn't switch back to knife.

Last edited by EpicMonkey; 08-27-2012 at 11:58.
EpicMonkey is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:13.


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