01.10.2009, 15:27
Ok guys, I need a bit of help here, i'm not understanding why the textdraw strings are not updating. Basically the textdraw shown to the player should show the player who he is spectating's health and armour. It works fine, but the problem is that it is not updating. The SpectateUpdatePlayer callback is not being called- only once. Maybe i've made a simple mistake.
Thanks.
Somewhere:
Thanks.
Somewhere:
pawn Код:
new SpectateUpdateTimer[MAX_SERVER_PLAYERS];
pawn Код:
zcmd(spec, playerid, params[])
{
new specid;
if (!sscanf(params, "u", specid))
{
if(!IsPlayerConnected(specid)) return SendClientMessage(playerid, AAD_COLOR_GREY, "* That player is not connected.");
//if(specid == playerid) return SendClientMessage(playerid, red, "ERROR: You cannot spectate yourself");
if(GetPlayerState(specid) == PLAYER_STATE_SPECTATING && gSpectateID[specid] != INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Spectate: Player spectating someone else");
if(Player[playerid][pPlaying] == true && Player[playerid][pTeam] != T_REF) return SendClientMessage(playerid, AAD_COLOR_GREY, "* You can only spectate if you are not in a round.");
if(GetPlayerState(specid) != 1 && GetPlayerState(specid) != 2 && GetPlayerState(specid) != 3) return SendClientMessage(playerid, AAD_COLOR_GREY, "* Player not spawned");
if(Player[specid][pTeam] != Player[playerid][pTeam] && Player[playerid][pTeam] != T_REF) return SendClientMessage(playerid, AAD_COLOR_GREY, "* You can only spectate your own team.");
StartSpectate(playerid, specid);
}
else SendClientMessage(playerid, AAD_COLOR_GREY, "USAGE: /spec [playerid/PartofName]");
return 1;
}
pawn Код:
stock StartSpectate(playerid,specid)
{
for(new x=0; x<MAX_SERVER_PLAYERS; x++)
{
if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && gSpectateID[x] == playerid)
{
AdvanceSpectate(x);
}
}
if(IsPlayerInAnyVehicle(specid))
{
TogglePlayerSpectating(playerid, 1);
SetPlayerInterior(playerid,GetPlayerInterior(specid));
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(specid));
gSpectateID[playerid] = specid;
gSpectateType[playerid] = SPECTATE_TYPE_VEHICLE;
}
else
{
SetPlayerInterior(playerid,GetPlayerInterior(specid));
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, specid);
gSpectateID[playerid] = specid;
gSpectateType[playerid] = SPECTATE_TYPE_PLAYER;
}
gSpectating[playerid] = true;
SendClientMessage(playerid,AAD_COLOR_LIMEGREEN,">> START spectated called");
//SpectateUpdateTimer[playerid] = SetTimerEx("SpectateUpdatePlayer", 2000, false, "i", playerid);
SpectateUpdatePlayer(playerid);
return 1;
}
pawn Код:
SpectateUpdatePlayer(playerid)
{
//FunctionLog("SpectateUpdatePlayer");
new SM_PNstring [128];
new specname[MAX_PLAYER_NAME];
GetPlayerName(gSpectateID[playerid],specname,sizeof(specname));
format(SM_PNstring,128,"Spectating: ~p~%s",specname);
TextDrawSetString(SM_PN, SM_PNstring);
TextDrawShowForPlayer(playerid, SM_PN);
new SM_HAstring [256];
new Float:armour, Float:Health;
GetPlayerHealth(gSpectateID[playerid],Health);
GetPlayerArmour(gSpectateID[playerid], armour);
format(SM_HAstring,sizeof(SM_HAstring),"~r~Health: %.0f ~b~Armour: %.0f",Health, armour);
TextDrawSetString(SM_HA, SM_HAstring);
TextDrawShowForPlayer(playerid, SM_HA);
TextDrawShowForPlayer(playerid, SM_Team);
TextDrawHideForPlayer(playerid, CurrentTeamsTD);
new SM_IDstring [128];
format(SM_IDstring,sizeof(SM_IDstring),"Spectate ID: %d",gSpectateID[playerid]);
TextDrawSetString(SM_ID, SM_IDstring);
TextDrawShowForPlayer(playerid, SM_ID);
TextDrawShowForPlayer(playerid, SM_BBar);
spectating[playerid] = 1;
SendClientMessage(playerid,AAD_COLOR_LIMEGREEN,">> SpectateUpdatePlayer Called");
SpectateUpdateTimer[playerid] = SetTimerEx("SpectateUpdatePlayer", 2000, false, "i", playerid);
SendClientMessage(playerid,AAD_COLOR_LIMEGREEN,">> Timer Set to Update");
}