AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   save a id when client connect (https://forums.alliedmods.net/showthread.php?t=120543)

liryck 03-05-2010 22:15

save a id when client connect
 
hi there i want to save ID when client connect and doesn't change it just save it to show a menu.

and always check if that ID ( player ) is still in the server if not get a random ID.

what don't know at moment is to save id that doesn't change.

wrecked_ 03-05-2010 22:24

Re: save a id when client connect
 
?
Code:
new tempid public client_connect( id )     tempid = id
Need to be a little more specific.

liryck 03-05-2010 22:55

Re: save a id when client connect
 
i think in this, if i made it has u said it will changed when other player connect?

PHP Code:

public client_connect(id){
    
player++
    if(
player == 1){
        
p_id id
    
}
}
// a server with 10 slot.   the variable player should be 1 again when 9 ppl leave?
public client_disconnect(id){
   
player--


the next point is that p_id show it a menu i can make this?
PHP Code:

register_clcmd"say .scrim","ShowMenu",p_id"Shows The menu" 


wrecked_ 03-05-2010 22:59

Re: save a id when client connect
 
So you're trying to just get the first person that joins the server and display a menu to them?

EDIT: Here's my interpretation of what you're doing. new players

Code:
new tempid public plugin_init() {     register_plugin( "Firsy Player Menu", VERSION, "Wrecked" ) // :avast:         register_clcmd( "say /menudisp", "CMD_DispMenu" ) } public client_connect( id ) {     players++         if( players == 1 )         tempid = id } public client_disconnect( id ) {     players-- } public CMD_DispMenu( id ) {     if( id == tempid )         menu_display( id, yourmenu, 0 )             else         print_chat( id, print_chat, "You're not the first player!" ) }

Exolent[jNr] 03-05-2010 23:19

Re: save a id when client connect
 
Code:
#include < amxmodx > new g_iFirstPlayer; public plugin_init( ) {     register_clcmd( "say .scrim", "CmdScrim" ); } public client_putinserver( iPlayer ) {     if( !g_iFirstPlayer )     {         g_iFirstPlayer = iPlayer;                 PrintAllow( );     } } public client_disconnect( iPlayer ) {     if( iPlayer == g_iFirstPlayer )     {         g_iFirstPlayer = -1;         set_task( 2.0, "TaskChooseNewPlayer" );     } } public TaskChooseNewPlayer( ) {     new iPlayers[ 32 ], iNum;     get_players( iPlayers, iNum, "ch" );         g_iFirstPlayer = iNum ? iPlayers[ random( iNum ) ] : 0;         PrintAllow( ); } public CmdScrim( iPlayer ) {     if( iPlayer == g_iFirstPlayer )     {         // this player can say .scrim     }     else     {         client_print( iPlayer, print_chat, "You are not allowed to use this command." );     } } PrintAllow( ) {     client_print( g_iFirstPlayer, print_chat, "You are allowed to use .scrim command." ); }

liryck 03-05-2010 23:35

Re: save a id when client connect
 
can u explain me what's this make
PHP Code:

g_iFirstPlayer iNum iPlayersrandomiNum ) ] : 0

i know that it take another player but whats mean ? between iNum and iPlayers and the 0 at the end

wrecked_ 03-05-2010 23:37

Re: save a id when client connect
 
https://forums.alliedmods.net/showthread.php?t=79543

liryck 03-06-2010 11:28

Re: save a id when client connect
 
fix it

liryck 03-06-2010 12:52

Re: save a id when client connect
 
ok i have another question. i have this, the player choose a map right? i call this funct for the changemap and i set a bool to true.

my question is when the map change the bool will be true or it will be false?


PHP Code:

new boolnewmap false

public changelevel(){
    
ChangeMap( );
    
newmap true



Bugsy 03-06-2010 12:55

Re: save a id when client connect
 
Quote:

Originally Posted by liryck (Post 1109570)
ok i have another question. i have this, the player choose a map right? i call this funct for the changemap and i set a bool to true.

my question is when the map change the bool will be true or it will be false?


PHP Code:

new boolnewmap false

public changelevel(){
    
ChangeMap( );
    
newmap true



The entire plugin will reload at mapchange so all variables will return to default value..so false. If you want to save data between mapchanges you will need some kind of storage mechanism (files, nvault, SQL, etc)


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

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