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;
}
new Float:OldPosx, Float:OldPosy, Float:OldPosz;
new Float:OldPosx[MAX_PLAYERS], Float:OldPosy[MAX_PLAYERS], Float:OldPosz[MAX_PLAYERS];
new Float:OldPlayerPos[MAX_PLAYERS][3];
Or to save time and make it generally better:
pawn Код:
Also note how I named it 'OldPlayerPos'. It's more descriptive than 'OldPos'. 'OldPos' could mean anything. Old position of what? Old position of a vehicle, an object, a player, a squirrel? |