SA-MP Forums Archive
/find command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /find command (/showthread.php?tid=433877)



/find command - morha12 - 30.04.2013

hello,
i am need help with building a command.
the code is:
Код HTML:
new hfind
CMD:hfind(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return 1;//Rcon admin
    if(hfind = true)
    {
 	   new targetid; new Float:x, Float:y, Float:z;
  	   if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, -1, "Usage: /hfind (ID) ");
       GetPlayerPos(targetid, x, y, z);
 	   SetPlayerCheckpoint(playerid, x, y, z, 6.0);

 	   SetTimerEx("findPlayer", 1000, 1, "ii", targetid, playerid);
    }
    else if(hfind = false)
    {
   		 DisablePlayerCheckpoint(playerid);
    return 1;
}
i am a new scripter..
i want that the command will show me the player with check point and after we doing the command again its will disable the check point...

sorry for my bad english..

thanx for helpers


Re: /find command - morha12 - 30.04.2013

Hello?


Re : /find command - DaTa[X] - 30.04.2013

pawn Код:
new bool:hfind;
this is your problem i think


Re: /find command - Babul - 30.04.2013

the hfind variable is global, and can be used by 1 player at a time only. i suggest to add
pawn Код:
new hfind[MAX_PLAYERS];
...to make a variable for each player. then you need to change each hfind by f.ex. hfind[playerid]:
pawn Код:
CMD:hfind(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return 1;//Rcon admin
    hfind[playerid]=1-hfind[playerid];//this will trigger 1-0-1-0-1 etc.
    if(hfind[playerid] == true)
    {
        new targetid; new Float:x, Float:y, Float:z;
        if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, -1, "Usage: /hfind (ID) ");
        GetPlayerPos(targetid, x, y, z);
        SetPlayerCheckpoint(playerid, x, y, z, 6.0);
        SetTimerEx("findPlayer", 1000, 1, "ii", targetid, playerid);
    }
    else // if(hfind[playerid] == false)//not required, since the first "if" checks for the only truth. else its false here.
    {
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
can you please explain how the system is supposed to do? how does it work? especially the timer "findPlayer".

btw, there was a "possible unintented assignment" in if(hfind[playerid] = true), its supposed to be == for comparing values.

edit: editing my post, since i get what you want, i hope. done.
one trick for modifying a bollean (hfind), is to simply subtract it from 1.
1-0=1 and 1-1=0 an endless loop...
the question remains: whats the timer containing? is it removing the checkpoint?


Re: /find command - morha12 - 30.04.2013

i want that when the player typing /hfind again its disabling the checkpoint...
i made that this is updating the player location every few secends...

i am now checking the script..

Thank you for help!


Re: /find command - morha12 - 30.04.2013

Thank you its working!
just one thing,
can you give me the script that its updating the players pos?


Re: /find command - morha12 - 01.05.2013

Hello ?


Re: /find command - morha12 - 02.05.2013

someone know how can i do that the command will repeat?