/find command
#1

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
Reply
#2

Hello?
Reply
#3

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

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?
Reply
#5

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!
Reply
#6

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

Hello ?
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)