getclosest player.[how do we use] -
Kar - 20.07.2010
Is There A Tutorial On This Because I can't Find<.<
do i like erm
like this
pawn Код:
if(!strlen(params))
{
SendClientMessage(playerid, COLOR_ERROR, "Correct usage: /rob [ID]");
}
do i change that to getclosest player or something o.o
Re: getclosest player.[how do we use] -
John_F - 20.07.2010
umm...I think I speak for everyone when I say
whaaaaaaat?
Re: getclosest player.[how do we use] -
Kar - 20.07.2010
how do i use the getclosest player function. like if a player does not specific an id it gets the closestplayer and does the command eg and arrest command if someone does /ar 1 that id is arrested if someone does /ar the getclosestplayer function comes in esle return msg nooneclose enough to arrest etc.
Re: getclosest player.[how do we use] -
bartje01 - 20.07.2010
pawn Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 3, X, Y, Z) && i != playerid && GetPlayerColor(i) == 0xFF8000FF)
{
This is when you stand realllyyy close
Re: getclosest player.[how do we use] -
Kar - 20.07.2010
bumpkins its been 22 hours. i mean i use sscanf. heres one of my simple commands. could someone make it that u can do /drag id and just /drag and it will get the closest polayer if not a specific id if no players around return error.
pawn Код:
CMD:drag(playerid,params[])
{
new id,Float:x, Float:y, Float:z,idname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF00AAFF, "*USAGE: /drag [playerid / part of name]");
if(gTeam[playerid] != TEAM_COPS) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You are not a Police Officer!");
if (GetPlayerWantedLevel(id) <= 3) return SendClientMessage(playerid, 0xFF0000AA, "Error: This Player Does Not Have A Warrant Please Use /ar [playerid]");
if(id == playerid) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You Cannot Drag Yourself.");
if (!IsPlayerConnected(id)) SendClientMessage(playerid, RED, "Invalid id");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You Cannot Drag Yourself.");
if(IsPlayerInRangeOfPoint(id, 10, x, y, z)) return SendClientMessage(playerid, COLOR_GREY, "Player is not close enough!");
if(PlayerInfo[playerid][LastVeh] == 0) return SendClientMessage(playerid,red,"Go In A Vehicle Seat Before Doing That!");
{
PutPlayerInVehicle(playerid,PlayerInfo[playerid][LastVeh],1);
PutPlayerInVehicle(id,PlayerInfo[playerid][LastVeh],2);
new string[128];
format(string, 128, "You Have Dragged %s(%d) Into Your Vehicle", idname, id);
SendClientMessage(playerid, orange, string);
format(string, 128, "Officer %s(%d) Has Dragged You Into His Vehicle!", name, playerid);
SendClientMessage(id, orange, string);
}
return 1;
}
i'd really appreciate it<.<
Re: getclosest player.[how do we use] -
bartje01 - 20.07.2010
alright. You really need help now.
Maybe this can help you:
I made a fast command that when you type /cuff the player that is 3 feet away or less will be unable to move.
pawn Код:
if (strcmp("/cuff", cmdtext, true, 10) == 0)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 3, X, Y, Z) && i != playerid && GetPlayerColor(i) == 0xFF8000FF)
{
TogglePlayerControllable(i,0);
}
}
}
return 1;
}
I really hope this works for you and I also hope this is the thing you need.
Otherwise I'm afraid I can't help you out

SO please tell me this is it :P
Re: getclosest player.[how do we use] -
Kar - 20.07.2010
o so you dont actually have to use getclosestplayer option i understand now but i wanna know how to add this to my drag command xD ty for the help i'll be experimenting on ways of fitting it in
Re: getclosest player.[how do we use] -
bartje01 - 20.07.2010
alright let me try to make this
EDIT:
Here it is. Now lets pray alright? :P
At top:
pawn Код:
new DragTimer[MAX_PLAYERS];
forward Drag(giveplayerid, playerid);
onplayercommandthing
pawn Код:
if (strcmp(cmd, "/drag", true) == 0)
{
new giveplayerid = strval(tmp);
if(sapd[playerid] >=1)
{
tmp = strtok(cmdtext, idx);
giveplayerid = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /drag [playerid]");
return 1;
}
if(!IsPlayerConnected(giveplayerid))
{
format(string, sizeof(string), "%d is not an active player.", giveplayerid);
SendClientMessage(playerid,COLOR_RED, string);
return 1;
}
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_RED, "You cannot drag yourself!");
return 1;
}
if(DragTimer[playerid] <= 0)
{
if(IsPlayerConnected(giveplayerid) == 1)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(giveplayerid, x, y, z);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 3, X, Y, Z) && i != playerid && GetPlayerColor(i) == 0xFF8000FF)
{
GetPlayerName(giveplayerid, sendername, sizeof(sendername));
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "Officer %s started dragging %s", playername, sendername);
ProxDetector(30.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
DragTimer[playerid] = SetTimerEx("Drag", 1000, 1, "ii", playerid, giveplayerid);
TogglePlayerControllable(giveplayerid, 0);
return 1;
}
else SendClientMessage(playerid, COLOR_RED, " This player must be near you ");
}
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, " You are not a Cop");
}
return 1;
}
you know here to put this ofc.
pawn Код:
public Drag(giveplayerid, playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(giveplayerid, x, y, z);
SetPlayerPos(playerid, x, y+0.5, z);
SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
return 1;
}
I did my best for you.
Please god, let it work
Re: getclosest player.[how do we use] -
Toni - 20.07.2010
You could use PlayerToPlayer
This was
not made by me, I don't know who either but I found it in a script
pawn Код:
stock PlayerToPlayer(playerid, destid, Float:radius)
{
if(!IsPlayerConnected(playerid)) return -1; // Checks if player is connected
{
new Float:X, Float:Y, Float:Z; // Base x, y, z values
new Float:px, Float:py, Float:pz; //px, py, pz used to express
GetPlayerPos(playerid, X, Y, Z); //
GetPlayerPos(destid, px, py, pz); //
X = floatsub(X, px);
Y = floatsub(Y, py);
Z = floatsub(Z, pz);
if( ( radius > X && X > -radius ) &&
( radius > Y && Y > -radius ) &&
( radius > Z && Z > -radius ) ) return 1;
}
return 0;
}
that might be useful to get a player in range
Re: getclosest player.[how do we use] -
Kar - 20.07.2010
uhh what kind of command is that wtf lol i dont get it toggleplayer uncontrollable? thats not a drag command i cant even edit that>.< drag command is surpose to put the officer and the player in the last v used
public OnPlayerExitVehicle(playerid, vehicleid)
{
CheckForAdminVehicles(playerid);
PlayerInfo[playerid][LastVeh] = vehicleid;
return 1;
}
pawn Код:
CMD:drag(playerid,params[])
{
new id,Float:x, Float:y, Float:z,idname[MAX_PLAYER_NAME],name[MAX_PLAYER_NAME];
if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF00AAFF, "*USAGE: /drag [playerid / part of name]");
if(gTeam[playerid] != TEAM_COPS) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You are not a Police Officer!");
if (GetPlayerWantedLevel(id) <= 3) return SendClientMessage(playerid, 0xFF0000AA, "Error: This Player Does Not Have A Warrant Please Use /ar [playerid]");
if(id == playerid) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You Cannot Drag Yourself.");
if (!IsPlayerConnected(id)) SendClientMessage(playerid, RED, "Invalid id");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF00AAFF, "*ERROR: You Cannot Drag Yourself.");
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInRangeOfPoint(id, 10, x, y, z)) return SendClientMessage(playerid, COLOR_GREY, "Player is not close enough!");
if(PlayerInfo[playerid][LastVeh] == 0) return SendClientMessage(playerid,red,"Go In A Vehicle Seat Before Doing That!");
{
PutPlayerInVehicle(playerid,PlayerInfo[playerid][LastVeh],1);
PutPlayerInVehicle(id,PlayerInfo[playerid][LastVeh],2);
new string[128];
format(string, 128, "You Have Dragged %s(%d) Into Your Vehicle", idname, id);
SendClientMessage(playerid, orange, string);
format(string, 128, "Officer %s(%d) Has Dragged You Into His Vehicle!", name, playerid);
SendClientMessage(id, orange, string);
}
return 1;
}
since idk what command is that well i have no clue what you did