SA-MP Forums Archive
Friends / Name Tag System - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Friends / Name Tag System (/showthread.php?tid=291294)



Friends / Name Tag System - Knappen - 19.10.2011

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.


Re: Friends / Name Tag System - Knappen - 19.10.2011

bump!


Re: Friends / Name Tag System - Knappen - 20.10.2011

bumpdibump ! i really need to get this to work!


Re: Friends / Name Tag System - nilanjay - 20.10.2011

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
                }

            }



Re: Friends / Name Tag System - Knappen - 20.10.2011

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


Re: Friends / Name Tag System - =WoR=Varth - 20.10.2011

What is "IsPlayerNearPlayer"?


Re: Friends / Name Tag System - Knappen - 20.10.2011

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?