Get playerid
#1

How i can get the playerid by its name?
Reply
#2

Can you give me an example? ******
Reply
#3

I didnt found anything.
Reply
#4

Anyone knows a good function to get the playerid by its name?
Reply
#5

****** can you show me the code? I can't figure alone how to do it.
Reply
#6

PHP код:
stock ReturnUser(text[])
{
    new 
pos 0;
    while (
text[pos] < 0x21)
    {
        if(
text[pos] == 0) return INVALID_PLAYER_ID;
        
pos++;
    }
    new 
userid INVALID_PLAYER_ID;
    if(
isNumeric(text[pos]))
    {
        
userid strval(text[pos]);
        if(
userid >=&& userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
                
userid INVALID_PLAYER_ID;
            else return 
userid;
        }
    }
    new 
len strlen(text[pos]);
    new 
count3 0;
    new 
pname[MAX_PLAYER_NAME];
    for (new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
          {
            
GetPlayerName(ipnamesizeof (pname));
            if(
strcmp(pnametext[pos], truelen) == 0)
            {
                if(
len == strlen(pname)) return i;
                else
                {
                    
count3++;
                    
userid i;
                }
            }
        }
    }
    if(
count3 != 1)
    {
        
userid INVALID_PLAYER_ID;
    }
    return 
userid;

Reply
#7

the function give this error
Quote:

C:\Users\Acer\Desktop\samp03e_svr_R2_win32\gamemod es\sa-rp.pwn(536) : error 017: undefined symbol "isNumeric"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Reply
#8

SRY
PHP код:
stock isNumeric(const string[])
{
    new 
length=strlen(string);
    if (
length==0) return false;
    for (new 
0lengthi++)
    {
        if ((
string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') || (string[i]=='-' && i!=0) || (string[i]=='+' && i!=0))
        {
            return 
false;
        }
    }
    if (
length==&& (string[0]=='-' || string[0]=='+')) { return false; }
    return 
true;

Reply
#9

It's working! Thanks Marcel!
Reply
#10

No Problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)