Timer help
#1

dcmd_arrest(playerid, params[])
{
if (strlen(params))
{
id = strval(params);
if (IsPlayerConnected(id) && (gTeam[playerid] != TEAM_HEAL) && (gTeam[playerid] != TEAM_CIVIL) && (GetDistanceBetweenPlayers( playerid, id) < 5.0 ) && (GetPlayerWantedLevel(id) >= 4) && (gTeam[id] != TEAM_COPS) && (gTeam[id] != TEAM_CIA))
{
if(GetPlayerWantedLevel(id) == 4)
{
SendClientMessage(id, COLOR_RED , "You have been Arrested");
SendClientMessage(playerid, 0x00FF00AA, "Criminal arrested. Good Job!");
ResetPlayerWeapons(id);
SetPlayerHealth(id,100.0);
SetPlayerScore(playerid, GetPlayerScore( playerid ) +1 );
SetPlayerWantedLevel(id, 0);
SetPlayerColor(id,COLOR_WHITE);
GameTextForPlayer(playerid, "~y~Player Arrested~n~+1500$", 3500, 3);
GameTextForPlayer(id, "~r~You have been arrested~n~-1500$", 3500, 3);
GivePlayerMoney(id, -2000);
GivePlayerMoney(playerid, 2000);
SetPlayerPos(id, 2340.2749,2457.5000,14.968;
}
if(GetPlayerWantedLevel(id) == 5)
{
SendClientMessage(id, COLOR_RED , "You have been Arrested");
SendClientMessage(playerid, 0x00FF00AA, "Criminal arrested. Good Job!");
ResetPlayerWeapons(id);
SetPlayerHealth(id,100.0);
SetPlayerScore(playerid, GetPlayerScore( playerid ) +1 );
SetPlayerWantedLevel(id, 0);
SetPlayerColor(id,COLOR_WHITE);
GameTextForPlayer(playerid, "~y~Player Arrested~n~+2500$", 3500, 3);
GameTextForPlayer(id, "~r~You have been arrested~n~-2500$", 3500, 3);
GivePlayerMoney(id, -2500);
GivePlayerMoney(playerid, 2500);
SetPlayerPos(id, 2340.2749,2457.5000,14.968;
}
if(GetPlayerWantedLevel(id) >= 6)
{
SendClientMessage(id, COLOR_RED , "You have been Arrested");
SendClientMessage(playerid, 0x00FF00AA, "Criminal arrested. Good Job!");
ResetPlayerWeapons(id);
SetPlayerHealth(id,100.0);
SetPlayerScore(playerid, GetPlayerScore( playerid ) +1 );
SetPlayerWantedLevel(id, 0);
SetPlayerColor(id,COLOR_WHITE);
GameTextForPlayer(playerid, "~y~Player Arrested~n~+3000$", 3500, 3);
GameTextForPlayer(id, "~r~You have been arrested~n~-3000$", 3500, 3);
GivePlayerMoney(id, -3000);
GivePlayerMoney(playerid, 3000);
SetPlayerPos(id, 2340.2749,2457.5000,14.968;
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "You are not a Cop to use this, or there is no arrestable player nearby.");
}
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/arrest <playerid>\"");
}
return 1;
}














How Can i add timer to this command?
Reply
#2

I think you got to explain a little more what it going to do. And why?
Reply
#3

Yeah, what will the command do? Do you want that you can use /arrest every 20 secs?
Reply
#4

Hmm ok listen... This is an arrest command... When i arrest one player i want to tele him to jail and after sometime free him automactly...
Reply
#5

Quote:
Originally Posted by tour15
Hmm ok listen... This is an arrest command... When i arrest one player i want to tele him to jail and after sometime free him automactly...
Okey maybe I wrote wrong. What is the timer supposed to do? Free player from jail?
Reply
#6

Yeah like all cops and robbers script...
Reply
#7

Just make a timer that after ## seconds/minutes set players position to the place you want the player to release.

EDIT: Make it e.g:

Код:
if(GetPlayerWantedLevel(id) == 5)
     {
      SendClientMessage(id, COLOR_RED , "You have been Arrested");
      SendClientMessage(playerid, 0x00FF00AA, "Criminal arrested. Good Job!");
      ResetPlayerWeapons(id);
      SetPlayerHealth(id,100.0);
      SetPlayerScore(playerid, GetPlayerScore( playerid ) +1 );
      SetPlayerWantedLevel(id, 0);
      SetPlayerColor(id,COLOR_WHITE);
      GameTextForPlayer(playerid, "~y~Player Arrested~n~+2500$", 3500, 3);
      GameTextForPlayer(id, "~r~You have been arrested~n~-2500$", 3500, 3);
      GivePlayerMoney(id, -2500);
      GivePlayerMoney(playerid, 2500);
      SetPlayerPos(id, 2340.2749,2457.5000,14.9688);
<< TIMER AT THIS LINE >>
     }
Reply
#8

If i could do this my frined i wouldnt ask for help. Thank you for help me
Reply
#9

I will make it for you, hang on.
Reply
#10

Oh thank you m8. Thank you guys
Reply
#11

Okay, Put this on the end of your Script.

pawn Код:
forward arrester(playerid);
public arrester(playerid)
{
    SetPlayerInterior(playerid,0);
    SetPlayerPos(playerid, 0.0, 0.0, 0.0);
    SpawnPlayer(playerid);
    // Add anything you want...
  return 1;
}
Over all the
pawn Код:
SendClientMessage(id, COLOR_RED , "You have been Arrested");
in your /arrest command

add


pawn Код:
SetTimerEx("arrester",60000,0,"is",playerid);


Hope it works! Does it?


Reply
#12

The SetTimerEx placed in arrest command?
Reply
#13

Over all the
pawn Код:
SendClientMessage(id, COLOR_RED , "You have been Arrested");
in your /arrest command

add


pawn Код:
SetTimerEx("arrester",60000,0,"is",playerid);

Reply
#14

i got this errors


C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1489) : error 025: function heading differs from prototype
C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1491) : error 017: undefined symbol "playerid"
C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1492) : error 017: undefined symbol "playerid"
C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1493) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#15

Set the playerid to id (in these lines)

Thats what you use.
Reply
#16

ok now i got only this


C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1489) : error 025: function heading differs from prototype
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#17

i think i made it do you want to try it to my server?
Reply
#18

http://pastebin.com/m316467d0

In the "SetTimerEx" replace "time" with the amount of time you want (attention: its in miliseconds)
Reply
#19

C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1035) : error 029: invalid expression, assumed zero
C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1035) : error 017: undefined symbol "d"
C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1035) : error 029: invalid expression, assumed zero
C:\DOCUME~1\NIKOS\Desktop\GTASER~1\GAMEMO~1\cops.p wn(1035) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.



i got this
Reply
#20

oh sorry, in the "SetTimerEx"
instead of
Код:
%d
replace with
Код:
"d"
with those ""
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)