SA-MP Forums Archive
timer - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: timer (/showthread.php?tid=87102)



timer - sggassasin - 18.07.2009

hi i was looking for a timer for a pickup. so like if they walk into the pickup only that 1 person can have that pickup and evrey 30sec they get $1000 here is the code im useing

Код:
new Pickup;
public OnGameModeInit()
{
Pickup = CreatePickup(1210, 2 ,2019.7742,1344.4839,10.8203);
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup)
{
GivePlayerMoney(playerid,100000);
SendClientMessage(playerid,0x33AA33AA,"You Better Run They Gonna Whant That Money");
return 1;
}
return 1;
}
thx for ur time


Re: timer - MenaceX^ - 18.07.2009

https://sampwiki.blast.hk/wiki/setTimerEx


Re: timer - sggassasin - 18.07.2009

i looked at that it dont help me at all



Re: timer - refshal - 18.07.2009

pawn Код:
#include <a_samp>

new Pickup;

public OnGameModeInit()
{
Pickup = CreatePickup(1210, 2 ,2019.7742, 1344.4839, 10.8203);
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup)
{
GivePlayerMoney(playerid, 100000);
SendClientMessage(playerid, 0x33AA33AA, "You Better Run They Gonna Whant That Money");
SetTimerEx("Timer", 30000, 0, "i", playerid);
return 1;
}
return 1;
}

forward Timer(playerid);
public Timer(playerid)
{
GivePlayerMoney(playerid, 100000);
SetTimerEx("Timer", 30000, 0, "i", playerid);
return 1;
}



Re: timer - sggassasin - 18.07.2009

thx for the help man you wouldent happen to know how to make it so when the player picks it up no 1 can get the case and when that play dies the case drops and after like 1min it respawns at its location would you thx for the help


Re: timer - Karlip - 18.07.2009

eddy: You made the timer work everywhere,not only in the pickup. So,basically,if they leave the pickup they still get money every 30 sec.
You have to use variables or the PlayerToPoint function to do that.

Why did you add 2 timers? Just put one under a rotation.
Like this:
pawn Код:
SetTimerEx("Timer", 30000, 1, "i", playerid);
//-------------------------^ (rotation = true(1))
sggassasin: Use a variable to check if the player has the briefcase and use it on OnPlayerDeath with CreatePickup.


Re: timer - sggassasin - 18.07.2009

karlip thats what i whant so that you can run around with the case but when the person with the case dies it go back to its point :P





Re: timer - Karlip - 18.07.2009

Quote:
Originally Posted by sggassasin
karlip thats what i whant so that you can run around with the case but when the person with the case dies it go back to its point :P
Ok,the 30 sec timer was to give money to the guy as a reward for holding the briefcase.
That's all good then.
pawn Код:
#include <a_samp>

#define MAX_PLAYERS 200

new briefcase[MAX_PLAYERS]

//other stuff here(OnGameModeInit n' stuff)

public OnPlayerPickUpPickup(playerid, pickupid)
{
   if(pickupid == Pickup)
   {
     GivePlayerMoney(playerid, 100000);
     SendClientMessage(playerid, 0x33AA33AA, "You Better Run They Gonna Whant That Money");
     SetTimerEx("Timer", 30000, 0, "i", playerid);
     briefcase[playerid] = 1;
     return 1;
   }
   return 1;
}

public OnPlayerDeath(playerid, reason)
{
   if(briefcase[playerid] == 1)
   {
     new Float:X,Float:Y,Float:Z;
     GetPlayerPos(playerid,X,Y,Z);
     Pickup = CreatePickup(1210, 2 ,X,Y,Z);
     briefcase[playerid] = 0;
   }
   return 1;
}



Re: timer - sggassasin - 18.07.2009

how do i do the check vribale thing


Re: timer - refshal - 18.07.2009

Quote:
Originally Posted by sggassasin
thx for the help man you wouldent happen to know how to make it so when the player picks it up no 1 can get the case and when that play dies the case drops and after like 1min it respawns at its location would you thx for the help
pawn Код:
#include <a_samp>

new Pickup;

new PlayerMoney;

new PlayerMoneyPickup;

public OnGameModeInit()
{
Pickup = CreatePickup(1212, 2, Float:x, Float:y, Float:z);
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PlayerMoney = GetPlayerMoney(playerid);
PlayerMoneyPickup = CreatePickup(1212, 2, Float:x, Float:y, Float:z);
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup)
{
GivePlayerMoney(playerid, amount);
DestroyPickup(Pickup);
return 1;
}
if(pickupid == PlayerMoneyPickup)
{
GivePlayerMoney(playerid, PlayerMoney);
DestroyPickup(PlayerMoneyPickup);
return 1;
}
return 1;
}
EDIT: Just put it into your filterscript. I didn't include everything, like I didn't include the timer.

@Karlip: Oh, I forgot that. :S


Re: timer - Karlip - 18.07.2009

eddy: Erm,check my post.


Re: timer - refshal - 18.07.2009

I already did that... Had to edit my post.


Re: timer - sggassasin - 18.07.2009

ok edde with ur script came up with these errors /warnings


C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(835) : warning 209: function "OnPlayerPickUpPickup" should return a value
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(835) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(839) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(841) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(461) : warning 204: symbol is assigned a value that is never used: "PlayerMoney"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(462) : warning 204: symbol is assigned a value that is never used: "PlayerMoneyPickup"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.


Re: timer - sggassasin - 18.07.2009

and with urs karlip came these warnings / errors



C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(33) : warning 201: redefinition of constant/macro (symbol "MAX_PLAYERS")
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(344) : error 017: undefined symbol "Pickup"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(463) : error 017: undefined symbol "briefcase"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(463) : warning 215: expression has no effect
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(463) : error 001: expected token: ";", but found "]"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(463) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(463) : fatal error 107: too many error messages on one line

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


5 Errors.






EDITk now after that post iv got these errors (from edde)


C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(827) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(833) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(835) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(839) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(841) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(344) : warning 204: symbol is assigned a value that is never used: "Pickup"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(461) : warning 204: symbol is assigned a value that is never used: "PlayerMoney"
C:\Program Files\Rockstar Games\GTA San Andreas\samp sever\gamemodes\asfr.pwn(462) : warning 204: symbol is assigned a value that is never used: "PlayerMoneyPickup"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.


Re: timer - refshal - 18.07.2009

Use the 'Modify' button...

pawn Код:
#include <a_samp>

new Pickup;

new PlayerMoney;

new PlayerMoneyPickup;

public OnGameModeInit()
{
Pickup = CreatePickup(1212, 2, 2019.7742,1344.4839,10.8203);
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PlayerMoney = GetPlayerMoney(playerid);
PlayerMoneyPickup = CreatePickup(1212, 2, Float:x, Float:y, Float:z);
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup)
{
GivePlayerMoney(playerid, 100000);
SendClientMessage(playerid, 0x33AA33AA, "You Better Run They Gonna Whant That Money");
SetTimerEx("Timer", 30000, 0, "i", playerid);
DestroyPickup(Pickup);
return 1;
}
if(pickupid == PlayerMoneyPickup)
{
GivePlayerMoney(playerid, PlayerMoney);
DestroyPickup(PlayerMoneyPickup);
return 1;
}
return 1;
}

forward Timer(playerid);
public Timer(playerid)
{
GivePlayerMoney(playerid, 100000);
SetTimerEx("Timer", 30000, 0, "i", playerid);
return 1;
}
@Karlip: If you got any suggestions, then spit out...


Re: timer - sggassasin - 18.07.2009

im still getting those errors a little help



Re: timer - refshal - 18.07.2009

You placed it wrong in your gamemode/filterscript, because there's nothing wrong. Try compiling it as a seperate filterscript.


Re: timer - sggassasin - 18.07.2009

ah ok i got it working some how i deleted this line

public OnPlayerPickUpPickup(playerid, pickupid)
{


so like lol now it works thx for the help man


Re: timer - sggassasin - 18.07.2009

um eddy when the person dides he still gain money


Re: timer - MenaceX^ - 18.07.2009

I can only suggest you to read some guides, start with wiki.