/makeadmin help
#3

Add this at bottom of your script:
PHP код:
ReturnUser(text[], playerid INVALID_PLAYER_ID)
{
    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])) // Check whole passed string
    
{
        
userid strval(text[pos]);
        if (
userid >= && userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
            {
                
userid INVALID_PLAYER_ID;
            }
            else
            {
                return 
userid// A player was found
            
}
        }
    }
    
// They entered [part of] a name or the id search failed (check names just incase)
    
new len strlen(text[pos]);
    new 
count 0;
    new 
name[MAX_PLAYER_NAME];
    catch(
Playeri)
    {
        
GetPlayerName(inamesizeof (name));
        if (
strcmp(nametext[pos], truelen) == 0// Check segment of name
        
{
            if (
len == strlen(name)) // Exact match
            
{
                return 
i// Return the exact player on an exact match
                // Otherwise if there are two players:
                // Me and MeYou any time you entered Me it would find both
                // And never be able to return just Me's id
            
}
            else 
// Partial match
            
{
                
count++;
                
userid i;
            }
        }
    }
    if (
count != 1)
    {
        if (
playerid != INVALID_PLAYER_ID)
        {
            if (
count)
            {
                
SendClientMessage(playerid0xFF0000AA"Au fost gasiti mai multi utilizatori, te rugam sa cauti mai detaliat");
            }
            else
            {
                
SendClientMessage(playerid0xFF0000AA"Nu a fost gasit un utilizator potrivit");
            }
        }
        
userid INVALID_PLAYER_ID;
    }
    return 
userid// INVALID_USER_ID for bad return

Reply


Messages In This Thread
/makeadmin help - by Christian_Bojic - 24.07.2011, 20:04
Re: /makeadmin help - by Shockey HD - 24.07.2011, 20:06
Re: /makeadmin help - by MoroDan - 24.07.2011, 20:08
Re: /makeadmin help - by Christian_Bojic - 24.07.2011, 20:08
Re: /makeadmin help - by Vince - 24.07.2011, 20:09
Re: /makeadmin help - by Christian_Bojic - 24.07.2011, 20:10
Re: /makeadmin help - by MoroDan - 24.07.2011, 20:12
Re: /makeadmin help - by Christian_Bojic - 24.07.2011, 20:15

Forum Jump:


Users browsing this thread: 1 Guest(s)