18.03.2011, 13:15
Saque esto del GF, te dejo las dos funciones, y un ejemplo en el comando /tazer.
Tazer
y Las dos funciones..
Eso serнa el "PlayerToPlayer", lo otro podes usar un timer global. Creo que eso queres, saludos.
pawn Код:
if(strcmp(cmd, "/tazer", true) ==0)
{
if(IsPlayerConnected(playerid))
{
if(gTeam[playerid] == 2 || IsACop(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Cannot use this while being in the Car !");
return 1;
}
new suspect = GetClosestPlayer(playerid);
if(IsPlayerConnected(suspect))
{
if(PlayerCuffed[suspect] > 0)
{
SendClientMessage(playerid, COLOR_GREY, " Player already Cuffed !");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,suspect) < 5)
{
if(gTeam[suspect] == 2)
{
SendClientMessage(playerid, COLOR_GREY, " Cannot Tazer Cops / FBI / National Guard !");
return 1;
}
if(IsPlayerInAnyVehicle(suspect))
{
SendClientMessage(playerid, COLOR_GREY, " Suspect is in a Car, get him out first !");
return 1;
}
GetPlayerName(suspect, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* You were Tazed by %s for 8 seconds.", sendername);
SendClientMessage(suspect, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* You Tazed %s for 8 seconds.", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s shoots with his Tazer at %s, and tazed him.", sendername ,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
GameTextForPlayer(suspect, "~r~Tazed", 2500, 3);
TogglePlayerControllable(suspect, 0);
PlayerCuffed[suspect] = 1;
PlayerCuffedTime[suspect] = 8;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " No-one near you!");
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not a Cop / FBI / National Guard !");
}
}//not connected
return 1;
}
y Las dos funciones..
pawn Код:
forward GetClosestPlayer(p1);
forward Float:GetDistanceBetweenPlayers(p1,p2);
public 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));
}
public GetClosestPlayer(p1)
{
new x,Float:dis,Float:dis2,player;
player = -1;
dis = 99999.99;
for (x=0;x<MAX_PLAYERS;x++)
{
if(IsPlayerConnected(x))
{
if(x != p1)
{
dis2 = GetDistanceBetweenPlayers(x,p1);
if(dis2 < dis && dis2 != -1.00)
{
dis = dis2;
player = x;
}
}
}
}
return player;
}