Having more IsPlayerInRangeOfPoint
#1

I currently have this code:

PHP код:
hook OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
PRESSED(KEY_WALK))
    {
        if(
IsPlayerInAnyVehicle(playerid)) return 0;
        new 
_mercID IsPlayerNearMercenary(playerid);
        if(
_mercID == -1) return 0;
        
        
ShowPlayerMercenaryInv(playerid_mercID);
    }
    
    return 
1;

But I wanted to remove "IsPlayerNearMercenary(playerid)" since I can't deal with it. It would be good if IsPlayerNearMercenary(playerid) can have many IsPlayerInRangeOfPoint, it's this:

PHP код:
IsPlayerNearMercenary(playerid)
{
    for(new 
i<MAX_MERCENARIESi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid1.5MercenaryInfo[i][mercPosX], MercenaryInfo[i][mercPosY], MercenaryInfo[i][mercPosZ]))
            return 
i;
    }
    return -
1;

I've tried it changing to this but it doesn't work:

PHP код:
IsPlayerNearMercenary(playerid)
{
    for(new 
i<MAX_MERCENARIESi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid1.5, -2817.39331, -1516.39526140.74620))
        if(
IsPlayerInRangeOfPoint(playerid1.5, -2386.691412216.228525.07300))
        if(
IsPlayerInRangeOfPoint(playerid1.5499.88400, -223.2224013.35980))
        if(
IsPlayerInRangeOfPoint(playerid1.5, -417.85309, -1754.719976.46650))
        if(
IsPlayerInRangeOfPoint(playerid1.5, -663.983702316.17261138.87550))
            return 
i;
    }
    return -
1;

Now to get back, that OnPlayerKeyStateChange, I want to change the part of "IsPlayerNearMercenary" to those different IsPlayerInRangeOfPoint, unless I know how to make IsPlayerNearMercenary work with different IsPlayerInRangeOfPoint. Thanks, I'll totally +rep who ever helps me how to do it.
Reply
#2

Well, I forgot about that. I just can't get it to work tho I don't know what I'm doing wrong here:

PHP код:
IsPlayerNearMercenary(const playerid)
{
    for(new 
i<MAX_MERCENARIESi++)
    {
        if(!
strcmp(IsPlayerInRangeOfPoint(playerid1.5, -2817.39331, -1516.39526140.74620) || !strcmp(IsPlayerInRangeOfPoint(playerid1.5, -2386.691412216.228525.07300))
            return 
i;
    }
    return -
1;

Utils/Mercenary.pwn(190) : error 035: argument type mismatch (argument 1)
Utils/Mercenary.pwn(191) : error 035: argument type mismatch (argument 1)

Line 190:

PHP код:
        if(!strcmp(IsPlayerInRangeOfPoint(playerid1.5, -2817.39331, -1516.39526140.74620) || !strcmp(IsPlayerInRangeOfPoint(playerid1.5, -2386.691412216.228525.07300)) 
Line 191:

PHP код:
return i

EDIT: fixed it


+rep
Reply
#3

or using else
pawn Код:
if(IsPlayerInRangeOfPoint(playerid...
else if(IsPlayerInRangeOfPoint(playerid..
Reply
#4

I've already fixed it, thanks.

Quote:
Originally Posted by DarkMythHunter
EDIT: fixed it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)