Distance from that player
#1

I have problem with command, it works great but I want to add if that player I want to arrest to far from me it will return him message "Player is not near you" I think here I should use IsPlayerInRangeOfPoint but I don't know how to do rest at that code :/ may you help me out please ? And thanks in advance
Reply
#2

Anyone please ? :/
Reply
#3

Please can we see your code?
Reply
#4

Use something like this:

pawn Код:
new giveplayerid; // this would be your other player's ID variable, but change it to your own...

new Float:x, Float:y, Float:z; // float positions
GetPlayerPos(playerid, Float:x, Float:y, Float:z); // Get the officer's position
if(IsPlayerInRangeOfPoint(giveplayerid, 5.0, x, y, z); // If the giveplayerid is in the range of the radius 5 from the playerid
{
    // Your code for the arrest command
    return 1;
}
else
{
    SendClientMessage(playerid, 0xFFFFFFFF, "You are not near that player.");
    return 1;
}
Reply
#5

This is what I wanted, but what about this?

if(!IsPlayerInRangeOfPoint(giveplayerid, 5.0, x, y, z);

Instead of this:

if(IsPlayerInRangeOfPoint(giveplayerid, 5.0, x, y, z);

Is same thing or.. ?
Reply
#6

Adding the ! means that it's not. So adding the ! to the start of IsPlayerInRangeOfPoint is literally if the player ISN'T in range of the point.

So by adding that to your code (the !), it will mean that if the player is not in the range of 5.0 it will do something under that line. And under the else means that it will do it if the player is in range of that point.
Reply
#7

By the way you've a little error in your code DanishHaq. It should be

pawn Код:
if(IsPlayerInRangeOfPoint(giveplayerid, 5.0, x, y, z))
Reply
#8

Well thank you guys but I was going on with scripting what does that mean ?
pawn Код:
(539) : error 048: array dimensions do not match
And here is error line:
pawn Код:
GetWeaponName(Weapon,WN, sizeof(WN));
and here are my "new"
pawn Код:
new
        id,
        Slot,
        Weapon,
        Ammo,
        CNT,
        X,
        Str[128],
        Float:x,
        Float:y,
        Float:z,
        Name[MAX_PLAYER_NAME];
And weapon names.
pawn Код:
new WN[][32] =
{
    {"Unarmed"}, {"Brass Knuckles"}, {"Golf Club"}, {"Night Stick"}, {"Knife"}, {"Baseball Bat"}, {"Shovel"}, {"Pool Cue"}, {"Katana"}, {"Chainsaw"},
    {"Purple Dildo"}, {"Big White Vibrator"}, {"Medium White Vibrator"}, {"Small White Vibrator"}, {"Flowers"}, {"Cane"}, {"Grenade"}, {"Teargas"}, {"Molotov"},
    {" "}, {" "}, {" "}, {"Colt 45"}, {"Colt 45 (Silenced)"}, {"Desert Eagle"}, {"Normal Shotgun"}, {"Sawnoff Shotgun"}, {"Combat Shotgun"}, {"Micro Uzi (Mac 10)"},
    {"MP5"}, {"AK47"}, {"M4"}, {"Tec9"}, {"Country Rifle"}, {"Sniper Rifle"}, {"Rocket Launcher"}, {"Heat-Seeking Rocket Launcher"}, {"Flamethrower"}, {"Minigun"},
    {"Satchel Charge"}, {"Detonator"}, {"Spray Can"}, {"Fire Extinguisher"}, {"Camera"}, {"Night Vision Goggles"}, {"Infrared Vision Goggles"}, {"Parachute"}, {"Fake Pistol"}
};
What should cause this error ? :/
Reply
#9

Bump
Reply
#10

Just use it as WN[GetPlayerWeapon(playerid)]
pawn Код:
// Example:
new
    test_msg[ 32 ]
;
format( test_msg, sizeof( test_msg ), "The weapon's name is \"%s\"", WN[ GetPlayerWeapon( playerid ) ] );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)