SA-MP Forums Archive
/hire, when someone is near to you - 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: /hire, when someone is near to you (/showthread.php?tid=448735)



/hire, when someone is near to you - cecko1235 - 05.07.2013

I made a command /hire [id] with which the leader of any faction can /hire people to his faction. Okay, the command working but I want to make only when the TARGET is nearly to him.

I mean, something like this

When he isn't near to you
/hire 1 ---- The person isn't nearly to you

When he's near to you
/hire 1 ---- plInfo[playerid][pRank] = 1.........

Would someone help me?


Re: /hire, when someone is near to you - Necip - 05.07.2013

Use ProxDetectorS:
pawn Код:
ProxDetectorS(Float:radi, playerid, targetid) {
        new
            Float: fp_playerPos[3];

        GetPlayerPos(targetid, fp_playerPos[0], fp_playerPos[1], fp_playerPos[2]);

        if(IsPlayerInRangeOfPoint(playerid, radi, fp_playerPos[0], fp_playerPos[1], fp_playerPos[2]) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid))
        {
            return 1;
        }
    return 0;
}



Re: /hire, when someone is near to you - cecko1235 - 05.07.2013

Thanks, I will try it!

I tried something different, and .. failed xD

Код:
 public OnPlayerText(playerid, text[])
{
	new message[128];
	format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
	if(ProxDetectorS(30.0, playerid, targetid)
	{
	ProxDetector(30.0, playerid, message, COLOR_WHITE);
	}
	if(ProxDetectorS(60.0, playerid, targetid)
	{
	ProxDetector(60.0, playerid, message, COLOR_GREY);
	}

	return 0;
}
error 017: undefined symbol "targetid" x2


Re: /hire, when someone is near to you - ToiletDuck - 05.07.2013

Not that lol show the /hire strcmp cmd


Re: /hire, when someone is near to you - Necip - 05.07.2013

Hmm, watch your code carefully:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid; // You didn't define "targetid"
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid)
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }
    if(ProxDetectorS(60.0, playerid, targetid)
    {
    ProxDetector(60.0, playerid, message, COLOR_GREY);
    }

    return 0;
}



Re: /hire, when someone is near to you - cecko1235 - 05.07.2013

Quote:
Originally Posted by ToiletDuck
Посмотреть сообщение
Not that lol show the /hire strcmp cmd
I made /hire command, but now I have problem with this -.-

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
Thanks, I will try it!

I tried something different, and .. failed xD

Код:
 public OnPlayerText(playerid, text[])
{
	new message[128];
	format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
	if(ProxDetectorS(30.0, playerid, targetid)
	{
	ProxDetector(30.0, playerid, message, COLOR_WHITE);
	}
	if(ProxDetectorS(60.0, playerid, targetid)
	{
	ProxDetector(60.0, playerid, message, COLOR_GREY);
	}

	return 0;
}
error 017: undefined symbol "targetid" x2



Re: /hire, when someone is near to you - ToiletDuck - 05.07.2013

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
I made /hire command, but now I have problem with this -.-
No, you should put that under /hire cmd before the function..

Post your /hire cmd and i'll try to explain.


Re: /hire, when someone is near to you - Necip - 05.07.2013

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
I made /hire command, but now I have problem with this -.-
My post may help you ^^


Re: /hire, when someone is near to you - cecko1235 - 05.07.2013

Hm, new problem.

Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid;
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid))
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }
    if(ProxDetectorS(60.0, playerid, targetid))
    {
    ProxDetector(60.0, playerid, message, COLOR_GREY);
    }

    return 0;
}
When I type something in the chat, it appears two times. ex:

Danny taylon says: test ( in white ) and then
Danny Taylon says: test (in grey) xD


Re: /hire, when someone is near to you - Necip - 05.07.2013

Quote:
Originally Posted by cecko1235
Посмотреть сообщение
Hm, new problem.

Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid;
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid))
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }
    if(ProxDetectorS(60.0, playerid, targetid))
    {
    ProxDetector(60.0, playerid, message, COLOR_GREY);
    }

    return 0;
}
When I type something in the chat, it appears two times. ex:

Danny taylon says: test ( in white ) and then
Danny Taylon says: test (in grey) xD
Remove ProxDetectorS:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], targetid;
    format(message, sizeof(message), "%s Says: %s", GetName(playerid), text);
    if(ProxDetectorS(30.0, playerid, targetid))
    {
    ProxDetector(30.0, playerid, message, COLOR_WHITE);
    }

    return 0;
}