Help Me Please About Utils In My GameMode
#1

i have problems in my gamemode
Код:
fatal error 100: cannot read from file: "utils"
i have a utils.inc in my pawno/include but still not working
This is my utils.inc :
Код:
IsNumeric(const string[])
{
	for (new i = 0, j = strlen(string); i < j; i++)
	{
		if (string[i] > '9' || string[i] < '0') return 0;
	}
	return 1;
}

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))
			{
				/*if (playerid != INVALID_PLAYER_ID)
				{
					SendClientMessage(playerid, 0xFF0000AA, "User not connected");
				}*/
				userid = INVALID_PLAYER_ID;
			}
			else
			{
				return userid; // A player was found
			}
		}
		/*else
		{
			if (playerid != INVALID_PLAYER_ID)
			{
				SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
			}
			userid = INVALID_PLAYER_ID;
		}
		return userid;*/
		// Removed for fallthrough code
	}
	// 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
					// 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(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
			}
			else
			{
				SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
			}
		}
		userid = INVALID_PLAYER_ID;
	}
	return userid; // INVALID_USER_ID for bad return
}
Reply
#2

Edit: Deleted
Reply
#3

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
Edit: Deleted
Please Give Me A Code
Reply
#4

Make sure you are running correct pawno were you have that include
Reply
#5

Quote:
Originally Posted by doreto
Посмотреть сообщение
Make sure you are running correct pawno were you have that include
I'm Vietnamese I don't know much about English !
is this ?
Код:
#include <utils>
Reply
#6

It's simple. If you cannot fix it, then add these two functions to the bottom of your mode.
Reply
#7

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
It's simple. If you cannot fix it, then add these two functions to the bottom of your mode.
Please Give Me A code
Reply
#8

Re-read what I said. ADD these 2 functions into your gamemode, the code is in front of your eyes.

pawn Код:
#include <a_samp>
// more includes and defines

main() {}

public OnGameModeInit()
{
    // add your code here
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// Rest of your callbacks

IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}

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))
            {
                /*if (playerid != INVALID_PLAYER_ID)
                {
                    SendClientMessage(playerid, 0xFF0000AA, "User not connected");
                }*/

                userid = INVALID_PLAYER_ID;
            }
            else
            {
                return userid; // A player was found
            }
        }
        /*else
        {
            if (playerid != INVALID_PLAYER_ID)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
            }
            userid = INVALID_PLAYER_ID;
        }
        return userid;*/

        // Removed for fallthrough code
    }
    // 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
                    // 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(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
            }
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid; // INVALID_USER_ID for bad return
}
Reply
#9

Quote:
Originally Posted by _Zeus
Посмотреть сообщение
Re-read what I said. ADD these 2 functions into your gamemode, the code is in front of your eyes.

pawn Код:
#include <a_samp>
// more includes and defines

main() {}

public OnGameModeInit()
{
    // add your code here
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// Rest of your callbacks

IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}

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))
            {
                /*if (playerid != INVALID_PLAYER_ID)
                {
                    SendClientMessage(playerid, 0xFF0000AA, "User not connected");
                }*/

                userid = INVALID_PLAYER_ID;
            }
            else
            {
                return userid; // A player was found
            }
        }
        /*else
        {
            if (playerid != INVALID_PLAYER_ID)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
            }
            userid = INVALID_PLAYER_ID;
        }
        return userid;*/

        // Removed for fallthrough code
    }
    // 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
                    // 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(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
            }
        }
        userid = INVALID_PLAYER_ID;
    }
    return userid; // INVALID_USER_ID for bad return
}
Thank You Zeus
But it have a other problem
fatal error 100: cannot read from file: "yom_buttons"
Reply
#10

Quote:
Originally Posted by xganyx
Посмотреть сообщение
Thank You Zeus
But it have a other problem
fatal error 100: cannot read from file: "yom_buttons"
Please Help Me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)