SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 02/06/2020, 03:05 AM   #1
Geremias1533
Big Clucker
 
Join Date: Dec 2017
Posts: 51
Reputation: 0
Default Timer

Segundo esse código, ele seria uma taxa de atualização da Pickup. E ele está funcionando de 3 em 3 segundos.

Alguem pode me explicar como eu devo mudar pra ele mandar/setar de 10 em 10 segundos ?

PHP Code:
public OnPlayerPickUpPickup(playeridpickupid)
{
    new 
PKTime[MAX_PLAYERS];
    if(
gettime() - PKTime[playerid] >= 60)
    {
        if(
pickupid == Motosserra)
        {
               if(
PlayerInfo[playerid][Profs] == Lenhador)
                {
                   
SendClientMessage(playerid, -1,"| LENHADOR | Você pegou uma motosserra de trabalho.");
                
GivePlayerWeapon(playerid91);
            } else return 
SendClientMessage(playeridVermelho"| ERRO | Você não tem permissão!");
        }
    }
    
PKTime[playerid] = gettime();
    return 
1;

Geremias1533 is offline   Reply With Quote
Old 02/06/2020, 01:48 PM   #2
Khivory
Huge Clucker
 
Khivory's Avatar
 
Join Date: Feb 2020
Posts: 364
Reputation: 23
Default Re: Timer

PHP Code:
if(gettime() < PKTime[playerid]) {
    
PKTime[playerid] = gettime() + 10;

Khivory is offline   Reply With Quote
Old 02/06/2020, 08:46 PM   #3
Geremias1533
Big Clucker
 
Join Date: Dec 2017
Posts: 51
Reputation: 0
Default Re: Timer

Funcionou não. Depois que foi mudado nenhuma pickup pegou
Geremias1533 is offline   Reply With Quote
Old 03/06/2020, 04:19 AM   #4
rjjj
Huge Clucker
 
rjjj's Avatar
 
Join Date: Jan 2014
Location: Acre, Brasil
Posts: 319
Reputation: 222
Default Re: Timer

A array PKTime é local e criada com new, não mantendo os valores entre diferentes chamadas do OnPlayerPickUpPickup. Mude new para static.



Aliás, quanto mais o jogador acionar a callback, mais longo o tempo a ser esperado (60 segundos) ficará. Para resolver isso, mude a posição da linha :



pawn Code:
PKTime[playerid] = gettime();


Para dentro do if de maior abrangência. Com isso tudo feito, troque 60 por 10 nessa condicional.



Espero ter ajudado .
__________________


rjjj is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer ID stored in a variable gets wiped when timer hits ? NeXoR Scripting Help 2 25/03/2017 07:22 PM
Performance Question , Per Player Timer vs Timer that loops through all players BiosMarcel Scripting Help 14 12/12/2016 09:50 AM
If /foodsearch doesn't find item, set wait timer (TIMER HELP) Josh_Main Scripting Help 7 14/09/2016 04:13 PM
Which is better Per Player Timer or Global timer? (issue with timer) Dokins Scripting Help 4 07/06/2016 09:50 AM
Slice's Timer Fix include --> timer public function isn't getting called Riwerry Scripting Help 0 02/01/2016 03:50 PM


All times are GMT. The time now is 08:13 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.