Timer not starting
#1

pawn Код:
forward InizioBici(playerid);
public InizioBici(playerid)
{
    Lorenzo[playerid] = SetTimerEx("Mobike1", 1000, true, "d", playerid);
    new vid = GetPlayerVehicleID(playerid);
    TextDrawShowForPlayer(playerid, Textdrawbike0);
    TextDrawShowForPlayer(playerid, Textdrawbike1);
    PlayerTextDrawShow(playerid, Textdrawbike2[playerid]);
    PlayerTextDrawShow(playerid, Textdrawbike3[playerid]);
    GetVehicleParamsEx(VeicoloAffittato[playerid], Engine[vid], Lights[vid], alarm[vid], doors[vid], bonnet[vid], boot[vid], objective[vid]);
    SetVehicleParamsEx(VeicoloAffittato[playerid], 1, Lights[vid], alarm[vid], doors[vid], bonnet[vid], boot[vid], objective[vid]);
    return 1;
}
forward Mobike1(playerid);
public Mobike1(playerid)
{
new ore[MAX_PLAYERS], minuti[MAX_PLAYERS], secondi[MAX_PLAYERS];
new string[126], str[126], str1[126];
new prezzo1[MAX_PLAYERS];
new prezzo[MAX_PLAYERS];
prezzo1[playerid] = ore[playerid]*60+minuti[playerid];
prezzo[playerid] = prezzo1[playerid]/15;
if(VeicoloAffittato[playerid] > 1)
{
if(Character[playerid][Bank] < prezzo[playerid]/2)
{
TextDrawHideForPlayer(playerid, Textdrawbike0);
TextDrawHideForPlayer(playerid, Textdrawbike1);
PlayerTextDrawHide(playerid, Textdrawbike2[playerid]);
PlayerTextDrawHide(playerid, Textdrawbike3[playerid]);
format(string, sizeof(string), "Hai terminato i soldi sul conto in banca. Hai speso $%d.", prezzo[playerid]*2);
SendClientMessage(playerid, COLOR_WHITE, string);
Character[playerid][Bank] -= prezzo[playerid]/2;
KillTimer(Lorenzo[playerid]);
return 1;
}
if(ore[playerid] == 0 && minuti[playerid] == 0 && secondi[playerid] > 0)
{
secondi[playerid]++;
format(str, sizeof(str), "Tempo trascorso: %ds", secondi[playerid]);
PlayerTextDrawSetString(playerid,Textdrawbike2[playerid], str);
format(str1, sizeof(str1), "Costo: %d$", prezzo[playerid]*2);
PlayerTextDrawSetString(playerid, Textdrawbike3[playerid], str);
return 1;
}
else if(secondi[playerid] == 60)
{
secondi[playerid] = 0;
minuti[playerid] ++;
format(str, sizeof(str), "Tempo trascorso: %dm %ds",minuti[playerid],secondi[playerid]);
PlayerTextDrawSetString(playerid, Textdrawbike2[playerid], str);
format(str1, sizeof(str1), "Costo: %d$", prezzo[playerid]*2);
PlayerTextDrawSetString(playerid, Textdrawbike3[playerid], str);
return 1;
}
else if(minuti[playerid] == 60)
{
minuti[playerid] = 0;
ore[playerid]++;
format(str, sizeof(str), "Tempo trascorso: %so %dm %ds", ore[playerid], minuti[playerid], secondi[playerid]);
PlayerTextDrawSetString(playerid, Textdrawbike2[playerid], str);
format(str1, sizeof(str1), "Costo: %d$", prezzo[playerid]*2);
PlayerTextDrawSetString(playerid, Textdrawbike3[playerid], str);
return 1;
}
else if(VeicoloAffittato[playerid] == 0)
{
TextDrawHideForPlayer(playerid, Textdrawbike0);
TextDrawHideForPlayer(playerid, Textdrawbike1);
PlayerTextDrawHide(playerid, Textdrawbike2[playerid]);
PlayerTextDrawHide(playerid, Textdrawbike3[playerid]);
format(string, sizeof(string), "Hai terminato il noleggio. Hai speso $%d che ti sono stati addebitati sulla carta di credito.", prezzo[playerid]*2);
SendClientMessage(playerid, COLOR_WHITE, string);
Character[playerid][Bank] -= prezzo[playerid]*2;
KillTimer(Lorenzo[playerid]);
return 1;
}
}
return 1;
}
Sorry for the identation.
TextDraws in InizioBici are showing but the timer is not starting.
Help me please
Reply
#2

Try
Код:
Lorenzo[playerid] = SetTimerEx("Mobike1", 1000, true, "i", playerid);
Reply
#3

Quote:
Originally Posted by RowdyrideR
Посмотреть сообщение
Try
Код:
Lorenzo[playerid] = SetTimerEx("Mobike1", 1000, true, "i", playerid);
d and i are not the same? (Integrer)

same problem
Reply
#4

here is a proper indentation for the code
PHP код:
forward InizioBici(playerid);
public 
InizioBici(playerid)
{
    
Lorenzo[playerid] = SetTimerEx("Mobike1"1000true"d"playerid);
    new 
vid GetPlayerVehicleID(playerid);
    
TextDrawShowForPlayer(playeridTextdrawbike0);
    
TextDrawShowForPlayer(playeridTextdrawbike1);
    
PlayerTextDrawShow(playeridTextdrawbike2[playerid]);
    
PlayerTextDrawShow(playeridTextdrawbike3[playerid]);
    
GetVehicleParamsEx(VeicoloAffittato[playerid], Engine[vid], Lights[vid], alarm[vid], doors[vid], bonnet[vid], boot[vid], objective[vid]);
    
SetVehicleParamsEx(VeicoloAffittato[playerid], 1Lights[vid], alarm[vid], doors[vid], bonnet[vid], boot[vid], objective[vid]);
    return 
1;
}
forward Mobike1(playerid);
public 
Mobike1(playerid)
{
    new 
ore[MAX_PLAYERS], minuti[MAX_PLAYERS], secondi[MAX_PLAYERS];
    new 
string[126], str[126], str1[126];
    new 
prezzo1[MAX_PLAYERS];
    new 
prezzo[MAX_PLAYERS];
    
prezzo1[playerid] = ore[playerid]*60+minuti[playerid];
    
prezzo[playerid] = prezzo1[playerid]/15;
    if(
VeicoloAffittato[playerid] > 1)
    {
        if(
Character[playerid][Bank] < prezzo[playerid]/2)
        {
            
TextDrawHideForPlayer(playeridTextdrawbike0);
            
TextDrawHideForPlayer(playeridTextdrawbike1);
            
PlayerTextDrawHide(playeridTextdrawbike2[playerid]);
            
PlayerTextDrawHide(playeridTextdrawbike3[playerid]);
            
format(stringsizeof(string), "Hai terminato i soldi sul conto in banca. Hai speso $%d."prezzo[playerid]*2);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
Character[playerid][Bank] -= prezzo[playerid]/2;
            
KillTimer(Lorenzo[playerid]);
            return 
1;
            }
        if(
ore[playerid] == && minuti[playerid] == && secondi[playerid] > 0)
        {
            
secondi[playerid]++;
            
format(strsizeof(str), "Tempo trascorso: %ds"secondi[playerid]);
            
PlayerTextDrawSetString(playerid,Textdrawbike2[playerid], str);
            
format(str1sizeof(str1), "Costo: %d$"prezzo[playerid]*2);
            
PlayerTextDrawSetString(playeridTextdrawbike3[playerid], str);
            return 
1;
            }
        else if(
secondi[playerid] == 60)
        {
            
secondi[playerid] = 0;
            
minuti[playerid] ++;
            
format(strsizeof(str), "Tempo trascorso: %dm %ds",minuti[playerid],secondi[playerid]);
            
PlayerTextDrawSetString(playeridTextdrawbike2[playerid], str);
            
format(str1sizeof(str1), "Costo: %d$"prezzo[playerid]*2);
            
PlayerTextDrawSetString(playeridTextdrawbike3[playerid], str);
            return 
1;
            }
        else if(
minuti[playerid] == 60)
        {
            
minuti[playerid] = 0;
            
ore[playerid]++;
            
format(strsizeof(str), "Tempo trascorso: %so %dm %ds"ore[playerid], minuti[playerid], secondi[playerid]);
            
PlayerTextDrawSetString(playeridTextdrawbike2[playerid], str);
            
format(str1sizeof(str1), "Costo: %d$"prezzo[playerid]*2);
            
PlayerTextDrawSetString(playeridTextdrawbike3[playerid], str);
            return 
1;
            }
        else if(
VeicoloAffittato[playerid] == 0)
        {
            
TextDrawHideForPlayer(playeridTextdrawbike0);
            
TextDrawHideForPlayer(playeridTextdrawbike1);
            
PlayerTextDrawHide(playeridTextdrawbike2[playerid]);
            
PlayerTextDrawHide(playeridTextdrawbike3[playerid]);
            
format(stringsizeof(string), "Hai terminato il noleggio. Hai speso $%d che ti sono stati addebitati sulla carta di credito."prezzo[playerid]*2);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
Character[playerid][Bank] -= prezzo[playerid]*2;
            
KillTimer(Lorenzo[playerid]);
            return 
1;
            }
        }
    return 
1;

Regarding your problem, where do you call the Callback InizioBici(playerid) ?
Reply
#5

In CMDcannerizza, and I'm sure that InizioBici is called, is only the timer not starting
Reply
#6

Show the CMD
Reply
#7

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Show the CMD
it's just
pawn Код:
CMD:scannerizza(playerid, params[])
{
InizioBici(playerid);
return 1;
}
Reply
#8

Why dont change the whole Mobikel lines to just one line as a “sendclintmessage” to make sure the problem is from the callback itself (not working), or it works but the lines inside it isnt.
Reply
#9

Just tried this:
pawn Код:
public mobike1(playerid)
{
SendClientMessage(playerid, COLOR_WHITE, "Timer works.");
KillTimer(Lorenzo[playerid]);
return 1;
}
And same SetTimerEx line before, and it perfectly works, so there is an issue in my mobike1 public, I will check

EDIT:

Fixed!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)