TextDraw problem -
calin1996 - 27.05.2012
Functions:
pawn Код:
public Spectator()
{
new string[450];
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Spectate[i] != 255)
{
new targetid = Spectate[i];
if(IsPlayerConnected(targetid))
{
if(PlayerInfo[i][pAdmin] >= 1)
{
new Float:health,Float:armour,Float:health2;
new name[MAX_PLAYER_NAME];
new money = GetPlayerMoney(targetid);
new carid = GetPlayerVehicleID(targetid);
new Float:km = GetPlayerSpeed(targetid);
new bankmoney = PlayerInfo[targetid][pAccount];
GetPlayerName(targetid, name, sizeof(name));
GetPlayerHealth(targetid, health);
GetPlayerArmour(targetid, armour);
GetVehicleHealth(carid, health2);
if(!IsPlayerInAnyVehicle(targetid))
{
format(string, sizeof(string),"~p~- ~h~%s (ID: %d) ~p~-~n~~n~~n~ ~b~Viata: ~w~%.1f ~g~:-: ~b~Armura: ~w~%.1f ~n~ ~b~Bani: ~w~$%d ~g~:-: ~b~Banca: ~w~$%d",name,targetid,health,armour,money,bankmoney);
TextDrawSetString(Textdraw54[i],string);
PlayerSpectatePlayer(i, targetid);
Textdraw54 = TextDrawCreate(29.000000, 426.000000,"-");
}
else
{
format(string, sizeof(string),"~p~- ~h~%s (ID: %d) ~p~-~n~~n~~n~ ~b~Viata ~w~%.1f ~g~:-: ~b~Armura: ~w~%.1f ~n~ ~b~Bani: ~w~$%d ~g~:-: ~b~Banca: ~w~$%d ~n~~n~~g~---------------------------------------------------~n~~n~ ~b~ID Masina: ~w~%d ~b~HP masina: ~w~%.1f ~n~~n~~b~Viteza: ~w~%d",name,targetid,health,armour,money,bankmoney,carid,health2,km);
TextDrawSetString(Textdraw54[i],string);
PlayerSpectateVehicle(i, carid);
Textdraw54 = TextDrawCreate(29.000000, 426.000000,"-");
}
}
SetPlayerInterior(i,GetPlayerInterior(targetid));
SetPlayerVirtualWorld(i,GetPlayerVirtualWorld(targetid));
}
}
}
}
}
Lines:
pawn Код:
3178: Textdraw54 = TextDrawCreate(29.000000, 426.000000,"-");
pawn Код:
3185: Textdraw54 = TextDrawCreate(29.000000, 426.000000,"-");
Errors:
pawn Код:
D:\Lucru\1.3 samp 0.3e\gamemodes\inaintedetaxi2.pwn(3178) : error 033: array must be indexed (variable "Textdraw54")
D:\Lucru\1.3 samp 0.3e\gamemodes\inaintedetaxi2.pwn(3185) : error 033: array must be indexed (variable "Textdraw54")
Re: TextDraw problem -
MP2 - 27.05.2012
Textdraw54 is defined as an array, so it should be Textdraw54[x] = TextDrawCreate(..);
Though you should really name your varibles better. You'll come back to your code in the future and say 'what the fuck is Textdraw54?'
AW: TextDraw problem -
Drebin - 27.05.2012
You should create TextDraws in OnGameModeInit. So put
pawn Код:
Textdraw54 = TextDrawCreate(29.000000, 426.000000,"-");
under OnGameModeInit.
Re: TextDraw problem -
MP2 - 27.05.2012
Drebin, that is neither correct nor relevant.
If you want a textdraw that is displayed when a player is spectating, you create it when they start spectating. Using player-textdraws would also be a good idea.
You should be using something like TD_pSpectate[playerid]. Not Textdraw54.
Re: TextDraw problem -
calin1996 - 27.05.2012
pawn Код:
new Text:Textdraw54[MAX_PLAYERS];
pawn Код:
if(!IsPlayerInAnyVehicle(targetid))
{
format(string, sizeof(string),"~p~- ~h~%s (ID: %d) ~p~-~n~~n~~n~ ~b~Viata: ~w~%.1f ~g~:-: ~b~Armura: ~w~%.1f ~n~ ~b~Bani: ~w~$%d ~g~:-: ~b~Banca: ~w~$%d",name,targetid,health,armour,money,bankmoney);
TextDrawSetString(Textdraw54[i],string);
PlayerSpectatePlayer(i, targetid);
}
else
{
format(string, sizeof(string),"~p~- ~h~%s (ID: %d) ~p~-~n~~n~~n~ ~b~Viata ~w~%.1f ~g~:-: ~b~Armura: ~w~%.1f ~n~ ~b~Bani: ~w~$%d ~g~:-: ~b~Banca: ~w~$%d ~n~~n~~g~---------------------------------------------------~n~~n~ ~b~ID Masina: ~w~%d ~b~HP masina: ~w~%.1f ~n~~n~~b~Viteza: ~w~%d",name,targetid,health,armour,money,bankmoney,carid,health2,km);
TextDrawSetString(Textdraw54[i],string);
PlayerSpectateVehicle(i, carid);
}
This is Textdraw54