Friends / Name Tag System
#1

I''ve made this function so that if I write "My name is Knappen", it checks my player name from a MySQL database, and then it's supposed to add my name into all the player's mysql tables, but only the players nearby me. My only problem is this:


pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(strfind(result, NameTagInfo[playerid][nFirstName], true) != -1 || strfind(result, NameTagInfo[playerid][nLastName], true) != -1)
                {
                    if(IsPlayerNearPlayer(i, playerid, 5))
                    {
                        if(NameTagInfo[i][nFriend1] == 0 && i != playerid)
                        {
                            SendClientMessage(i, COLOR_YELLOW, "It Worked");
                            return 1;
                        }
                }
            }
I started scripting not that long ago, and I've been studying up on loops lately, to understand how to use it. But as you see, I can't get it to work.

I would be very grateful if anyone could help me. If you need more information about the script/function, don't hesitate to ask.
Reply
#2

bump!
Reply
#3

bumpdibump ! i really need to get this to work!
Reply
#4

You are missing one things
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(strfind(result, NameTagInfo[playerid][nFirstName], true) != -1 || strfind(result, NameTagInfo[playerid][nLastName], true) != -1)
                {
                    if(IsPlayerNearPlayer(i, playerid, 5))
                    {
                        if(NameTagInfo[i][nFriend1] == 0 && i != playerid)
                        {
                            SendClientMessage(i, COLOR_YELLOW, "It Worked");
                            return 1;
                        }
                    }// this
                }

            }
Reply
#5

sorry, got deleted when I pasted it here. It's in the script!
Reply
#6

What is "IsPlayerNearPlayer"?
Reply
#7

It's a function I got from the forums here

pawn Код:
forward IsPlayerNearPlayer(playerid, n_playerid, Float:radius);
IsPlayerNearPlayer(playerid, n_playerid, Float:radius)
{
    new Float:npx, Float:npy, Float:npz;
    GetPlayerPos(n_playerid, npx, npy, npz);
    if(IsPlayerInRangeOfPoint(playerid, radius, npx, npy, npz))
    {
        return true;
    }
    return false;
}
As far as I know, it should work. At first I tried with IsPlayerInRangeOfPoint, which would work, but I figured this was easier to use. I don't have to get the position all the time, which makes it easier. And the code looks pretty fine to me.

Anyways, is there anything wrong with my loop?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)