Having more IsPlayerInRangeOfPoint
#1

I currently have this code:

PHP код:
hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    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; i <MAX_MERCENARIES; i++)
    {
        if(
IsPlayerInRangeOfPoint(playerid, 1.5, MercenaryInfo[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; i <MAX_MERCENARIES; i++)
    {
        if(
IsPlayerInRangeOfPoint(playerid, 1.5, -2817.39331, -1516.39526, 140.74620))
        if(
IsPlayerInRangeOfPoint(playerid, 1.5, -2386.69141, 2216.22852, 5.07300))
        if(
IsPlayerInRangeOfPoint(playerid, 1.5, 499.88400, -223.22240, 13.35980))
        if(
IsPlayerInRangeOfPoint(playerid, 1.5, -417.85309, -1754.71997, 6.46650))
        if(
IsPlayerInRangeOfPoint(playerid, 1.5, -663.98370, 2316.17261, 138.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; i <MAX_MERCENARIES; i++)
    {
        if(!
strcmp(IsPlayerInRangeOfPoint(playerid, 1.5, -2817.39331, -1516.39526, 140.74620) || !strcmp(IsPlayerInRangeOfPoint(playerid, 1.5, -2386.69141, 2216.22852, 5.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(playerid, 1.5, -2817.39331, -1516.39526, 140.74620) || !strcmp(IsPlayerInRangeOfPoint(playerid, 1.5, -2386.69141, 2216.22852, 5.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)