AlliedModders

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

mwebmedia 07-20-2011 23:57

client_putinserver
 
hey guys,
have an small question about an small plugin. Dont blame me, im a new coder :)

i only want to show, steamid and name

Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN    "connect"
#define AUTHOR    "mwebmedia"
#define VERSION    "1.0"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
}

public client_putinserver(id) {
    new name[18]
    new userid[18]
        get_user_authid(id, userid, 17)
    get_user_name(id, name, 17)
    client_print(0, print_chat, "%s %d", userid, name);
    return PLUGIN_CONTINUE   
}

but it only shows the steamid and not the name, why?

Exolent[jNr] 07-21-2011 00:26

Re: client_putinserver
 
They are both strings, so you have to use %s for both.

gamer99 07-21-2011 02:27

Re: client_putinserver
 
new name[33]
new userid[18]
get_user_authid(id, userid, 17)
get_user_name(id, name, 32)
client_print(0, print_chat, "%s %s", userid, name);
return PLUGIN_CONTINUE

change the above lines

mwebmedia 07-21-2011 17:34

Re: client_putinserver
 
Okay thanks!
But can you tell me, why get_user_authid(id, userid, 17) sometimes dont post an steamid? at some people/sometimes its zero or a random number like 83 :/

Honors 07-21-2011 17:37

Re: client_putinserver
 
An AuthID has 34 characters, so -> new userid[ 35 ]

PS : Use the native charsmax( )

Code:
get_user_authid( id , userid , charsmax( userid ) )

mwebmedia 07-21-2011 17:48

Re: client_putinserver
 
Quote:

Originally Posted by Honors (Post 1515598)
An AuthID has 34 characters, so -> new userid[ 35 ]

PS : Use the native charsmax( )

Code:
get_user_authid( id , userid , charsmax( userid ) )

This Forum is so awesome! thanks for your help :)
So if I want to run an function of mine, only if one user connected, I musst do it with set_task in public client_putinserver()?

fysiks 07-21-2011 18:33

Re: client_putinserver
 
Quote:

Originally Posted by mwebmedia (Post 1515601)
So if I want to run an function of mine, only if one user connected, I musst do it with set_task in public client_putinserver()?

What exactly do you mean? Generally, you do not need to use a set task unless you need something delayed. So, it really depends on what you are trying to do.

Honors 07-21-2011 18:49

Re: client_putinserver
 
If I have understood, you can do this :

Code:
public function( id ) {      new players[ 32 ] , num , i , id      get_players( players , num , "ch" )      if( num >= 1 )      {           // stuff ...      } }

drekes 07-21-2011 18:54

Re: client_putinserver
 
Quote:

Originally Posted by Honors (Post 1515638)
If I have understood, you can do this :

Code:
new playerCount public function( id ) {      new players[ 32 ] , num , i , id      get_players( players , num , "ch" )      for( i = 0; i < num; i++ )      {           playerCount++      }      if( playerCount >= 1 )      {           // stuff ...      } }

num already holds the amount of players, you don't have to loop.

Exolent[jNr] 07-21-2011 18:55

Re: client_putinserver
 
Quote:

Originally Posted by Honors (Post 1515638)
If I have understood, you can do this :

Code:
new playerCount public function( id ) {      new players[ 32 ] , num , i , id      get_players( players , num , "ch" )      for( i = 0; i < num; i++ )      {           playerCount++      }      if( playerCount >= 1 )      {           // stuff ...      } }

In that code, playerCount will equal num. Pointless loop, just use num to compare.


All times are GMT -4. The time now is 01:09.

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