RevivingText[playerid] = Create3DTextLabel("(( |--------- ))\nHELPING UP", COLOR_DARKGREEN, pX, pY, pZ, 25.0, -1, 0);
reviveCount[playerid] = 0;
reviveTextTimer[playerid] = SetTimerEx("updateRevivingText", 500, true, "ddfff", playerid, reviveCount[playerid], pX, pY, pZ);
forward updateRevivingText(playerid, count, Float:x, Float:y, Float:z);
public updateRevivingText(playerid, count, Float:x, Float:y, Float:z)
{
switch(count)
{
case 0: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||-------- ))\nHELPING UP");
case 1: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||------- ))\nHELPING UP");
case 2: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||------ ))\nHELPING UP");
case 3: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||----- ))\nHELPING UP");
case 4: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||---- ))\nHELPING UP");
case 5: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||--- ))\nHELPING UP");
case 6: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||||-- ))\nHELPING UP");
case 7: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||- ))\nHELPING UP");
case 8: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||| ))\nHELPING UP");
case 9:
{
Delete3DTextLabel(RevivingText[playerid]);
KillTimer(reviveTextTimer[playerid]);
reviveCount[playerid] = 0;
count = 0;
return 1;
}
}
count++;
reviveCount[playerid]++;
return 1;
}
reviveCount[playerid] = 0;
reviveTextTimer[playerid] = SetTimerEx("updateRevivingText", 500, true, "d", playerid);
// position is not used in `Update3DTextLabelText` function and counter will be increased and checked in the callback
forward updateRevivingText(playerid);
public updateRevivingText(playerid)
{
switch (reviveCount[playerid]++) // ++ or -- after the variable returns the old value and then it increases/decreases
{
case 0: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||-------- ))\nHELPING UP");
case 1: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||------- ))\nHELPING UP");
case 2: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||------ ))\nHELPING UP");
case 3: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||----- ))\nHELPING UP");
case 4: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||---- ))\nHELPING UP");
case 5: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||--- ))\nHELPING UP");
case 6: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||||-- ))\nHELPING UP");
case 7: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||- ))\nHELPING UP");
case 8: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||| ))\nHELPING UP");
case 9:
{
Delete3DTextLabel(RevivingText[playerid]);
RevivingText[playerid] = Text3D: INVALID_3DTEXT_ID;
KillTimer(reviveTextTimer[playerid]);
reviveTextTimer[playerid] = -1; // always reset ids to avoid destroying/killing the wrong thing
reviveCount[playerid] = 0;
}
}
}
`count` is always 0, it does not matter if you modify its value in the callback. The initial value you passed in `SetTimerEx` is used.
pawn Code:
pawn Code:
|
I made some minor changes and added debugging, here's a picture.
https://prnt.sc/qm08km https://prnt.sc/qm06g8 https://prnt.sc/qm06t4 |
new timer_test;
main()
{
timer_test = SetTimerEx("OnTestParameterValue", 500, true, "d", 1);
}
forward OnTestParameterValue(value);
public OnTestParameterValue(value)
{
printf("OnTestParameterValue(%d);", value);
value++;
if (value == 5) KillTimer(timer_test);
}
OnTestParameterValue(1);
.
.
.
OnTestParameterValue(1);
You modify the parameter and print its new value which is misleading. Move the debug message at the top and see for yourself or here is a sample of code:
pawn Code:
pawn Code:
|
RevivingText[playerid] = Create3DTextLabel("(( |--------- ))\nHELPING UP", COLOR_DARKGREEN, pX, pY, pZ, 25.0, -1, 0); reviveCount[playerid] = 0; reviveTextTimer[playerid] = SetTimerEx("updateRevivingText", 500, true, "d", playerid); forward updateRevivingText(playerid); public updateRevivingText(playerid) { if(reviveCount[playerid] != 9) { switch(reviveCount[playerid]) { case 0: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||-------- ))\nHELPING UP"); case 1: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||------- ))\nHELPING UP"); case 2: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||------ ))\nHELPING UP"); case 3: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||----- ))\nHELPING UP"); case 4: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||---- ))\nHELPING UP"); case 5: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||--- ))\nHELPING UP"); case 6: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||||-- ))\nHELPING UP"); case 7: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||- ))\nHELPING UP"); case 8: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||| ))\nHELPING UP"); } reviveCount[playerid]++; } if(reviveCount[playerid] == 9) { Delete3DTextLabel(RevivingText[playerid]); reviveCount[playerid] = 0; KillTimer(reviveTextTimer[playerid]); } return 1; }
Code:
RevivingText[playerid] = Create3DTextLabel("(( |--------- ))\nHELPING UP", COLOR_DARKGREEN, pX, pY, pZ, 25.0, -1, 0); reviveCount[playerid] = 0; reviveTextTimer[playerid] = SetTimerEx("updateRevivingText", 500, true, "d", playerid); forward updateRevivingText(playerid); public updateRevivingText(playerid) { if(reviveCount[playerid] != 9) { switch(reviveCount[playerid]) { case 0: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||-------- ))\nHELPING UP"); case 1: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||------- ))\nHELPING UP"); case 2: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||------ ))\nHELPING UP"); case 3: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||----- ))\nHELPING UP"); case 4: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||---- ))\nHELPING UP"); case 5: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||--- ))\nHELPING UP"); case 6: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( ||||||||-- ))\nHELPING UP"); case 7: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||- ))\nHELPING UP"); case 8: Update3DTextLabelText(RevivingText[playerid], COLOR_DARKGREEN, "(( |||||||||| ))\nHELPING UP"); } reviveCount[playerid]++; } if(reviveCount[playerid] == 9) { Delete3DTextLabel(RevivingText[playerid]); reviveCount[playerid] = 0; KillTimer(reviveTextTimer[playerid]); } return 1; } |