IsPlayerInRangeOfPlayer work? -
ricardo178 - 13.03.2011
Hey, i have this stun cmd, but i can use it anywhere, even if i am in LS and suspect in LV! I want it, to only stun if player is near me...
CMD is this:
pawn Код:
COMMAND:stun(playerid, params[])
{
if(GetPlayerColor(playerid) == 0x0259EAAA)
{
new toplayer;
if(!sscanf(params, "ui", toplayer))
{
if(IsPlayerConnected(toplayer))
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Cop %s Has Stun You", name);
SendClientMessage(playerid, 0x0259EAAA, string);
format(string, sizeof(string), "You Has Stun %s", PlayerName);
SendClientMessage(playerid, 0x0259EAAA, string);
TogglePlayerControllable(playerid, 0);
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Conected.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /stun [PlayerId/PartOfName]");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Only Cops Can Use This Command.");
}
THANKS
Re: IsPlayerInRangeOfPlayer work? -
Hashski - 13.03.2011
The command
pawn Код:
COMMAND:stun(playerid, params[])
{
if(GetPlayerColor(playerid) == 0x0259EAAA)
{
new toplayer;
if(!sscanf(params, "ui", toplayer))
{
if(IsPlayerConnected(toplayer))
{
if(PlayerToPlayer(playerid,i,5.0) && i != playerid)
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Cop %s Has Stun You", name);
SendClientMessage(playerid, 0x0259EAAA, string);
format(string, sizeof(string), "You Has Stun %s", PlayerName);
SendClientMessage(playerid, 0x0259EAAA, string);
TogglePlayerControllable(playerid, 0);
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "You are not close enough to that player.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Conected.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /stun [PlayerId/PartOfName]");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Only Cops Can Use This Command.");
}
Function you need
pawn Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerInRangeOfPoint(playerid, radi, x, y, z))
{
return 1;
}
return 0;
}
Re: IsPlayerInRangeOfPlayer work? -
xRyder - 13.03.2011
Use it like this:
First get player pos:
pawn Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X,Y,Z);
And then use IsPlayerInRangeOfPoint() with if statement.
pawn Код:
IsPlayerInRangeOfPoint(Some_Other_PlayerID, Your_Range, X,Y,Z)
Re: IsPlayerInRangeOfPlayer work? -
ricardo178 - 13.03.2011
I get 1 error:
Код:
C:\Users\Ricardo\Desktop\Mini-DM\Mini-DM\Freedoom\filterscripts\copsystem.pwn(80) : error 017: undefined symbol "PlayerToPlayer"
C:\Users\Ricardo\Desktop\Mini-DM\Mini-DM\Freedoom\filterscripts\copsystem.pwn(129) : warning 235: public function lacks forward declaration (symbol "PlayerToPoint")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf>
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Cop System by Ricardo_Manuel");
print("--------------------------------------\n");
return 1;
}
COMMAND:duty(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, 1555.097900, -1675.848754, 16.195312))
{
SetPlayerColor(playerid, 0x0259EAAA);
SendClientMessage(playerid, 0x0259EAAA, "You Are Now A Cop, Use /equip To Get Weapons.");
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "You Are Not In LSPD Entrance.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Online");
}
COMMAND:dutyoff(playerid, params[])
{
if(GetPlayerColor(playerid) == 0x0259EAAA)
{
if(IsPlayerConnected(playerid))
{
SetPlayerColor(playerid, 0xFFFFFFAA);
ResetPlayerWeapons(playerid);
SendClientMessage(playerid, 0x0259EAAA, "You Are Now Off Duty.");
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Online");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Only Cops Can Use This Command.");
}
COMMAND:equip(playerid, params[])
{
if(GetPlayerColor(playerid) == 0x0259EAAA)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, 1555.097900, -1675.848754, 16.195312))
{
GivePlayerWeapon(playerid, 24, 1000);
GivePlayerWeapon(playerid, 25, 1000);
GivePlayerWeapon(playerid, 29, 1000);
GivePlayerWeapon(playerid, 31, 1000);
GivePlayerWeapon(playerid, 34, 1000);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "You Are Not At LSPD Entrance.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Online");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Only Cops Can Use This Command.");
}
COMMAND:stun(playerid, params[])
{
if(GetPlayerColor(playerid) == 0x0259EAAA)
{
new toplayer;
if(!sscanf(params, "ui", toplayer))
{
if(IsPlayerConnected(toplayer))
{
if(PlayerToPlayer(playerid,i,5.0) && i != playerid)
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Cop %s Has Stun You", name);
SendClientMessage(playerid, 0x0259EAAA, string);
format(string, sizeof(string), "You Has Stun %s", PlayerName);
SendClientMessage(playerid, 0x0259EAAA, string);
TogglePlayerControllable(playerid, 0);
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "You are not close enough to that player.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Conected.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /stun [PlayerId/PartOfName]");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Only Cops Can Use This Command.");
}
COMMAND:unstun(playerid, params[])
{
if(GetPlayerColor(playerid) == 0x0259EAAA)
{
new toplayer;
if(!sscanf(params, "ui", toplayer))
{
if(IsPlayerConnected(toplayer))
{
new string[64];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Cop %s Has UnStun You", name);
SendClientMessage(playerid, 0x0259EAAA, string);
format(string, sizeof(string), "You Has UnStun %s", PlayerName);
SendClientMessage(playerid, 0x0259EAAA, string);
TogglePlayerControllable(playerid, 1);
return 1;
}
else return SendClientMessage(playerid, 0x0259EAAA, "Player Is Not Conected.");
}
else return SendClientMessage(playerid, 0x0259EAAA, "USAGE: /unstun [PlayerId/PartOfName]");
}
else return SendClientMessage(playerid, 0x0259EAAA, "Only Cops Can Use This Command.");
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerInRangeOfPoint(playerid, radi, x, y, z))
{
return 1;
}
return 0;
}