i tried to create ped slots on screen like this mod:
https://www.youtube.com/watch?v=Ts1AAaWW2kc
but server side on samp
but sometimes the counter get wrong...
why?
there is any way that OnPlayerStreamIn/OnPlayerStreamOut can bug onplayerdisconnect, setplayerposs or somehow else?
or there is something wrong on my script?
script:
public OnPlayerStreamIn(playerid, forplayerid)
{
// se nao ta logado nem vai pra baixo
if(isLogged[playerid] == false) return 1;
if(isLogged[forplayerid] == false) return 1;
// anti double stream
if(isPlayerStreamed[playerid][forplayerid] == true) return 1;
isPlayerStreamed[playerid][forplayerid] = true;
// atualizar txds pedslots
if(gSpectateID[forplayerid] == 65535) {
pedslots[forplayerid] += 1;
KillTimerEx(timerUpdatePedSlots[forplayerid]);
timerUpdatePedSlots[playerid] = SetTimerEx("UpdatePedSlotsTxd", 1500, false, "i", forplayerid);
}
return true;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
// anti double stream
if(isPlayerStreamed[playerid][forplayerid] == false) return 1;
isPlayerStreamed[playerid][forplayerid] = false;
//
if(gSpectateID[forplayerid] == 65535) {
if(pedslots[forplayerid] > 0) pedslots[forplayerid] -= 1;
KillTimerEx(timerUpdatePedSlots[forplayerid]);
timerUpdatePedSlots[forplayerid] = SetTimerEx("UpdatePedSlotsTxd", 1500, false, "i", forplayerid);
}
return true;
}
public UpdatePedSlotsTxd(playerid) {
if(isLogged[playerid] == false) return 1;
// atualizar ped slots
new string[32];
format(string, sizeof(string), "peds: %d"
, pedslots[playerid]
);
PlayerTextDrawSetString(playerid, txdPedSlots[playerid], string);
PlayerTextDrawHide(playerid, txdPedSlots[playerid]);
PlayerTextDrawShowEx(playerid, txdPedSlots[playerid]);
return 1;
}