Help /makeadmin and /admins
#3

Oh thanks alot pal

but still got these warnings

Код:
C:\Users\User\Desktop\samp03dsvr_R2_win32\gamemodes\Daniel.pwn(7) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\samp03dsvr_R2_win32\gamemodes\Daniel.pwn(100) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\User\Desktop\samp03dsvr_R2_win32\gamemodes\Daniel.pwn(374) : warning 219: local variable "string" shadows a variable at a preceding level
Here are the lines

This is line 7-24

Код:
strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
Line 100

Код:
new string[128];
And line 309-381
Код:
stock ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
    new pos = 0;
    while (text[pos] < 0x21) // Strip out leading spaces
    {
        if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
        pos++;
    }
    new userid = INVALID_PLAYER_ID;
    if (IsNumeric(text[pos])) // Check whole passed string
    {
        // If they have a numeric name you have a problem (although names are checked on id failure)
        userid = strval(text[pos]);
        if (userid >=0 && 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];
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof (name));
            if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
            {
                if (len == strlen(name)) // Exact match
                {
                    return i; // Return the exact player on an exact match
                }
                else // Partial match
                {
                    count++;
                    userid = i;
                }
            }
        }
    }
    if (count != 1)
    {
        if (playerid != INVALID_PLAYER_ID)
        {
            if (count)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow search.");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found.");
            }
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid; // INVALID_PLAYER_ID for bad return
}
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Reply


Messages In This Thread
Help /makeadmin and /admins - by DannySnoopy - 03.02.2012, 12:28
Re: Help /makeadmin and /admins - by Konstantinos - 03.02.2012, 12:36
Re: Help /makeadmin and /admins - by DannySnoopy - 03.02.2012, 12:39
Re: Help /makeadmin and /admins - by DannySnoopy - 03.02.2012, 12:46
Re: Help /makeadmin and /admins - by Konstantinos - 03.02.2012, 12:50
Re : Help /makeadmin and /admins - by ricardo178 - 03.02.2012, 12:56
Re: Help /makeadmin and /admins - by DannySnoopy - 03.02.2012, 12:58
Re: Help /makeadmin and /admins - by Konstantinos - 03.02.2012, 13:02
Re: Help /makeadmin and /admins - by DannySnoopy - 03.02.2012, 13:03

Forum Jump:


Users browsing this thread: 1 Guest(s)