09.07.2014, 21:00
I've tried alot of GetClosestPlayer functions and all causes the same problem in SendClientMessage. I really don't know what exactly causes the problem, the GetClosestPlayer function or my arranging of the Scripting Lines.
Look At This:
The Error Message "There are no players close enough to rape." only appears if i make the //Comment Line compilable (uncommented), and doesn't appear if i make it as comment!
How to make the error message appears ? cuz i want to delete all the comment line.
GetClosestPlayer function: (originally posted by nmader)
Look At This:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys & KEY_LOOK_BEHIND) && !(oldkeys & KEY_LOOK_BEHIND))
{
if(PlayerTeam[playerid] == TEAM_CIV && AdminDuty[playerid] == false)
{
if(PlayerInfo[playerid][pSkill] == 1)
{
new targetid = GetClosestPlayer(playerid, 7.0);
if(IsKidnapped[playerid] == 1 && Spawned[playerid] == 0) return 1;
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[Error:] {FFFFFF}There are no players close enough to rape.");
//if(GetPlayerWantedLevel(targetid) == 0) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[Error:] {FFFFFF}There are no players close enough to rape.");
if(Spawned[targetid] == 0 || Freezed[targetid] == 1) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[Error:] {FFFFFF}There are no players close enough to rape.");
if(ArrestCuffed[targetid] == 1) return SendClientMessage(playerid, COLOR_RED, "You cannot rape cuffed players.");
}
}
}
return 1;
}
How to make the error message appears ? cuz i want to delete all the comment line.
GetClosestPlayer function: (originally posted by nmader)
pawn Код:
stock Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
stock GetClosestPlayer(playerid, Float:dis)
{
new x, Float:dis2, player;
player = -1;
for (x = 0; x < MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x) && x != playerid && GetPlayerState(x) != PLAYER_STATE_SPECTATING)
{
dis2 = GetDistanceBetweenPlayers(x,playerid);
if(dis2 < dis && dis2 != -1.00)
{
dis = dis2;
player = x;
}
}
}
return player;
}