CMD:rob(playerid, params[]) { if (sscanf( params, "r", ID )) SendClientMessage(playerid, 0xFF000AA, "Use: /rob [ID]"); else if (ID == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF000AA,"invalid Player ...."); else if(ID == playerid) SendClientMessage(ID, 0xFF0000AA, "ERROR : You cant rob yourself!"); return 1; }
stock GetClosestPlayer(playerid) { new Float:dis,Float:dis2,player; player = -1; dis = 99999.99; foreach(Player,x) { if(x != playerid) { dis2 = GetDistanceBetweenPlayers(x,playerid); if(dis2 < dis && dis2 != -1.00) { dis = dis2; player = x; } } } return player; } CMD:rob(playerid, params[]) { if(GetClosestPlayer(playerid) == -1) return SendClientMessage(ID, 0xFF0000AA, "ERROR : No player close to you!"); printf("Player with ID %i is closest to you!", GetClosestPlayer(playerid)); return 1; }
stock GetNearestPlayer(playerid)
{
new Float:dist = 1000.0;
new targetid = INVALID_PLAYER_ID;
new Float:x1,Float:y1,Float:z1;
new Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(i == playerid) continue;
GetPlayerPos(i,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
if(tmpdis < dist)
{
dist = tmpdis;
targetid = i;
}
}
return targetid;
}
CMD:rob(playerid, params[]) { new ID; return 1; }
new Float:dist = 1000.0;
stock GetNearestPlayer(playerid)
{
new Float:arr1[3], Float:arr2[3];
GetPlayerPos(playerid, arr1[0], arr1[1], arr1[2]);
for(new i; i <MAX_PLAYERS; i++)
{
if(i == playerid) continue;
GetPlayerPos(i, arr2[0], arr2[1], arr2[2]);
if(2.0 /* DISTANCE */ < floatsqroot(floatpower(floatabs(floatsub(arr1[0], arr2[0])),2)+floatpower(floatabs(floatsub(arr1[1], arr2[1])),2)+floatpower(floatabs(floatsub(arr1[2], arr2[2])),2))){
return i;
}
}
return -1;
}
CMD:rob(playerid, params[]) { new string[250], string2[250], string3[250], robbedcash, robbedname[MAX_PLAYER_NAME], robbername[MAX_PLAYER_NAME]; robbedcash = random(5000); if(sscanf( params, "u", ID )) SendClientMessage(playerid, 0xFF0000AA, "Usage /rob ID"); if(!GetNearestPlayer(playerid)) return SendClientMessage(ID, 0xFF0000AA, "ERROR : No player close to you!"); else(GetNearestPlayer(playerid)) return 1; }
duno if this might help mate im no pro but this is a command that you can put in /rob and it will say....
USAGE: /rob (playerid) but its abit messy an not finished so you will have to complete it mate as dont have the time today sorry man http://pastebin.com/44B0B2QH oops sorry this one might be better http://pastebin.com/qKrgjFEV if it does help mate please +rep i really could do with it lol |