new Text:Textdraw0; // MDC new Text:Textdraw1; // maverick seen new Text:Textdraw2; // siren
public OnPlayerUpdate(playerid) { TextDrawHideForPlayer(playerid,Textdraw1); TextDrawHideForPlayer(playerid,Textdraw2); /////////////////////////////////////////////////////////////////////////// if(team[playerid]==0) { new mavseenstring[25]; if(newmavseen==0) { format(mavseenstring,sizeof(mavseenstring),"Visual From Sky: ~r~No"); } if(newmavseen==1) { format(mavseenstring,sizeof(mavseenstring),"Visual From Sky: ~r~Yes"); } Textdraw1 = TextDrawCreate(388.000000, 310.000000, mavseenstring); TextDrawBackgroundColor(Textdraw1, 255); TextDrawFont(Textdraw1, 1); TextDrawLetterSize(Textdraw1, 0.500000, 1.000000); // "Visual From Sky: " TextDrawColor(Textdraw1, -16776961); TextDrawSetOutline(Textdraw1, 0); TextDrawSetProportional(Textdraw1, 1); TextDrawSetShadow(Textdraw1, 1); TextDrawShowForPlayer(playerid,Textdraw1); } /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// if(team[playerid]==0) { new sirenstring[15]; if(!IsPlayerInAnyVehicle(playerid)) { format(sirenstring,sizeof(sirenstring),"Siren: ~r~No"); } else { new vid=GetPlayerVehicleID(playerid); if(Siren[vid]==0) { format(sirenstring,sizeof(sirenstring),"Siren: ~r~No"); } if(Siren[vid]==1) { // siren info format(sirenstring,sizeof(sirenstring),"Siren: ~r~Yes"); } } Textdraw2 = TextDrawCreate(388.000000, 320.000000, sirenstring); TextDrawBackgroundColor(Textdraw2, 255); TextDrawFont(Textdraw2, 1); TextDrawLetterSize(Textdraw2, 0.500000, 1.000000); TextDrawColor(Textdraw2, -16776961); TextDrawSetOutline(Textdraw2, 0); TextDrawSetProportional(Textdraw2, 1); TextDrawSetShadow(Textdraw2, 1); TextDrawShowForPlayer(playerid,Textdraw2); } /////////////////////////////////////////////////////////////////////////// TextDrawHideForPlayer(playerid,Textdraw0); if(team[playerid]==0) { Textdraw0 = TextDrawCreate(560.000000, 312.000000, "Mobile Data Computer"); TextDrawBackgroundColor(Textdraw0, 255); TextDrawFont(Textdraw0, 1); TextDrawLetterSize(Textdraw0, 0.500000, 1.000000); TextDrawColor(Textdraw0, -1); TextDrawSetOutline(Textdraw0, 1); // Blue police box TextDrawSetProportional(Textdraw0, 1); TextDrawUseBox(Textdraw0, 1); TextDrawBoxColor(Textdraw0, 65535); TextDrawTextSize(Textdraw0, 384.000000, 165.000000); TextDrawShowForPlayer(playerid,Textdraw0); } }
You're going over the textdraw limit because you're recreating the same textdraw over and over again without ever deleting old ones. Use TextDrawSetString instead. Much easier. Also you would probably want to have a per-player textdraw ([MAX_PLAYERS]).
|
new Text:td_mavseen_no,
Text:td_mavseen_yes,
Text:td_siren_no,
Text:td_siren_yes,
Text:td_mobiledatacomputer;
public OnGameModeInit()
{
td_mavseen_no = TextDrawCreate(388.000000, 310.000000, "Visual From Sky: ~r~No");
TextDrawBackgroundColor(td_mavseen_no, 255);
TextDrawFont(td_mavseen_no, 1);
TextDrawLetterSize(td_mavseen_no, 0.500000, 1.000000);
TextDrawColor(td_mavseen_no, -16776961);
TextDrawSetOutline(td_mavseen_no, 0);
TextDrawSetProportional(td_mavseen_no, 1);
TextDrawSetShadow(td_mavseen_no, 1);
td_mavseen_yes = TextDrawCreate(388.000000, 310.000000, "Visual From Sky: ~r~Yes");
TextDrawBackgroundColor(td_mavseen_yes, 255);
TextDrawFont(td_mavseen_yes, 1);
TextDrawLetterSize(td_mavseen_yes, 0.500000, 1.000000);
TextDrawColor(td_mavseen_yes, -16776961);
TextDrawSetOutline(td_mavseen_yes, 0);
TextDrawSetProportional(td_mavseen_yes, 1);
TextDrawSetShadow(td_mavseen_yes, 1);
td_siren_no = TextDrawCreate(388.000000, 320.000000, "Siren: ~r~No");
TextDrawBackgroundColor(td_siren_no, 255);
TextDrawFont(td_siren_no, 1);
TextDrawLetterSize(td_siren_no, 0.500000, 1.000000);
TextDrawColor(td_siren_no, -16776961);
TextDrawSetOutline(td_siren_no, 0);
TextDrawSetProportional(td_siren_no, 1);
TextDrawSetShadow(td_siren_no, 1);
td_siren_yes = TextDrawCreate(388.000000, 320.000000, "Siren: ~r~Yes");
TextDrawBackgroundColor(td_siren_yes, 255);
TextDrawFont(td_siren_yes, 1);
TextDrawLetterSize(td_siren_yes, 0.500000, 1.000000);
TextDrawColor(td_siren_yes, -16776961);
TextDrawSetOutline(td_siren_yes, 0);
TextDrawSetProportional(td_siren_yes, 1);
TextDrawSetShadow(td_siren_yes, 1);
td_mobiledatacomputer = TextDrawCreate(560.000000, 312.000000, "Mobile Data Computer");
TextDrawBackgroundColor(td_mobiledatacomputer, 255);
TextDrawFont(td_mobiledatacomputer, 1);
TextDrawLetterSize(td_mobiledatacomputer, 0.500000, 1.000000);
TextDrawColor(td_mobiledatacomputer, -1);
TextDrawSetOutline(td_mobiledatacomputer, 1);
TextDrawSetProportional(td_mobiledatacomputer, 1);
TextDrawUseBox(td_mobiledatacomputer, 1);
TextDrawBoxColor(td_mobiledatacomputer, 65535);
TextDrawTextSize(td_mobiledatacomputer, 384.000000, 165.000000);
return 1;
}
public OnPlayerUpdate(playerid)
{
if(team[playerid] == 0)
{
TextDrawShowForPlayer(playerid, td_mobiledatacomputer);
if(newmavseen == 0)
{
TextDrawShowForPlayer(playerid, td_mavseen_no);
}
else
{
TextDrawShowForPlayer(playerid, td_mavseen_yes);
}
new vid = GetPlayerVehicleID(playerid);
if(vid && Siren[vid] == 1)
{
TextDrawShowForPlayer(playerid, td_siren_yes);
}
else
{
TextDrawShowForPlayer(playerid, td_siren_no);
}
}
else
{
TextDrawHideForPlayer(playerid, td_mobiledatacomputer);
TextDrawHideForPlayer(playerid, td_mavseen_yes);
TextDrawHideForPlayer(playerid, td_mavseen_no);
TextDrawHideForPlayer(playerid, td_siren_yes);
TextDrawHideForPlayer(playerid, td_siren_no);
}
return 1;
}
By the way Finn,
I realized that your script is creating new and new textdraws on player update. wont this cause huge overwriting on screen and big lags too? |
Thank you for your quick response. I quite dont understand that it doesnt have to be too accurate. I mean, onplayerupdate happens like 20 times a second, no? So it really should be accurate.
|