07.04.2013, 23:27
So, I am trying to make it so you can do a search in one spot, but you must move at least 10 SA Units away from the last spot you searched.
However, With my code, it just skips over the positioning part. Anyone know why?
However, With my code, it just skips over the positioning part. Anyone know why?
pawn Код:
CMD:search(playerid, params[])
{
new string[128];
new Float:x, Float:y, Float:z;
new Float:OldPosx, Float:OldPosy, Float:OldPosz;
GetPlayerPos(playerid, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 10.0, OldPosx, OldPosy, OldPosz))
{
if(Search[playerid] == 0)
{
format(string, sizeof(string), "* %s does a quick search of their surroundings.", GetPlayerNameEx(playerid));
nearByMessage(playerid, COLOR_PURPLE, string);
new randitem = Random(1,7);
switch(randitem)
{
case 1:
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have found Five Dollars! ($5.00)");
GivePlayerCash(playerid, 5);
}
case 2: SendClientMessageEx(playerid, COLOR_RED, "You didn't find anything.");
case 3:
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have found a Small Book of Matches! (4 Matches)");
}
case 4: SendClientMessageEx(playerid, COLOR_RED, "You didn't find anything.");
case 5:
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have found a Large Book of Matches! (8 Matches)");
}
case 6: SendClientMessageEx(playerid, COLOR_RED, "You didn't find anything.");
}
Search[playerid] = 1;
SetTimerEx("ClearSearch", 20000, false, "d", playerid);
GetPlayerPos(playerid, OldPosx, OldPosy, OldPosz);
}
else
return SendClientMessageEx(playerid, COLOR_RED, "You must wait 20 seconds before searching again.");
}
else
return SendClientMessageEx(playerid, COLOR_RED, "You can't search in the same spot twice!");
return 1;
}