SA-MP Forums Archive
[Textdraw] New Player steals the Textdraw - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Textdraw] New Player steals the Textdraw (/showthread.php?tid=67162)



[Textdraw] New Player steals the Textdraw - KingArthur - 27.02.2009

Hi,

i need your help.
If a player connected, he still steals my current textdraw *angry* *g*.
I don't see my mistake in my code.
I hope you find it.

Thanks.

...


Re: [Textdraw] New Player steals the Textdraw - hoodline - 27.02.2009

I cant understand you sorry

Can you explain what you trying to do with it?


Re: [Textdraw] New Player steals the Textdraw - Norn - 27.02.2009

First of all, put textdrawtimer = SetTimer("Anzeige",100,1); under OnGameModeInit, secondly learn to use else if.


Re: [Textdraw] New Player steals the Textdraw - sumwanyous - 27.02.2009

Quote:
Originally Posted by Norn
First of all, put textdrawtimer = SetTimer("Anzeige",100,1); under OnGameModeInit, secondly learn to use else if.
R U SERIOUS?! 100 ms timer?!


Re: [Textdraw] New Player steals the Textdraw - Finn - 27.02.2009

Quote:
Originally Posted by sumwanyous
R U SERIOUS?! 100 ms timer?!
Yes, he is serious. Now your script starts the timer when someone connects to your server, so it would be better if the timer was started once at the beginning and killed in the end, wouldn't it?

Also, do you know why you shouldn't make your strings 256 cells big?


Re: [Textdraw] New Player steals the Textdraw - Norn - 27.02.2009

Quote:
Originally Posted by sumwanyous
Quote:
Originally Posted by Norn
First of all, put textdrawtimer = SetTimer("Anzeige",100,1); under OnGameModeInit, secondly learn to use else if.
R U SERIOUS?! 100 ms timer?!
I just copy and pasted, obviously i wouldnt use a 100ms timer.


Re: [Textdraw] New Player steals the Textdraw - KingArthur - 27.02.2009

Thank you all for the answers, but thats all not the solve for my problem Its just coding-format-style-thing.

Quote:
Originally Posted by hoodline
I cant understand you sorry

Can you explain what you trying to do with it?
Well, if i'm the only one on the Server, it works all fine. I can see all textdraws, but if someone else joind, i don't see my textdraws anymore, but the connected people.
So i think only the last who joind can see the textdraws.

Is it possible, like in my example, that the OnPlayerRequestClass-Textdraw and Anzeige-Textdraw has "the same textdraw"?


Re: [Textdraw] New Player steals the Textdraw - JaYmE - 27.02.2009

pawn Code:
#include <a_samp>

new textdrawtimer;
new Text:status_unten[MAX_PLAYERS];

new killsvonplayer[MAX_PLAYERS], Float:lebenfloatvonplayer[MAX_PLAYERS],
Float:armourfloatvonplayer[MAX_PLAYERS], Float:vehiclehealthfloatvonplayer[MAX_PLAYERS];

forward Anzeige(playerid);

public Anzeige(playerid)
{
  new string[256];
  new vehiclehealthtext[256];
 
for (new i; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
  TextDrawDestroy(status_unten[i]);
 
      killsvonplayer[i] = GetPlayerScore(i);
      GetPlayerHealth(i,lebenfloatvonplayer[i]);
GetPlayerArmour(i,armourfloatvonplayer[i]);
GetVehicleHealth(GetPlayerVehicleID(i), vehiclehealthfloatvonplayer[i]);

if(IsPlayerInAnyVehicle(i))
{
if(vehiclehealthfloatvonplayer[i] > 650.0)
  {
  format(vehiclehealthtext, sizeof(vehiclehealthtext),"~w~VH:~g~ %.1f",vehiclehealthfloatvonplayer[i]-250);
}
  if(vehiclehealthfloatvonplayer[i] <= 650.0)
  {
  format(vehiclehealthtext, sizeof(vehiclehealthtext),"~w~VH:~g~ %.1f",vehiclehealthfloatvonplayer[i]-250);
}
if(vehiclehealthfloatvonplayer[i] <= 550.0)
  {
  format(vehiclehealthtext, sizeof(vehiclehealthtext),"~w~VH:~y~ %.1f",vehiclehealthfloatvonplayer[i]-250);
}
if(vehiclehealthfloatvonplayer[i] <= 450.0)
  {
  format(vehiclehealthtext, sizeof(vehiclehealthtext),"~w~VH:~y~ %.1f",vehiclehealthfloatvonplayer[i]-250);
}
if(vehiclehealthfloatvonplayer[i] <= 350.0)
  {
  format(vehiclehealthtext, sizeof(vehiclehealthtext),"~w~VH:~r~ %.1f Warning",vehiclehealthfloatvonplayer[i]-250);
}
if(vehiclehealthfloatvonplayer[i] <= 250.0)
  {
  format(vehiclehealthtext, sizeof(vehiclehealthtext),"~w~VH:~r~ %.1f Warning",vehiclehealthfloatvonplayer[i]-250);
}
if(vehiclehealthfloatvonplayer[i] < 250.0)
  {
  format(vehiclehealthtext, sizeof(vehiclehealthtext),"~w~VH:~r~ %.1f Warning",0);
}


format(string, sizeof(string),"P:~g~ %d  ~w~L:~g~ %.1f  ~w~A:~g~ %.1f  %s",killsvonplayer[i],lebenfloatvonplayer[i],armourfloatvonplayer[i], vehiclehealthtext);
status_unten[i] = TextDrawCreate(0.0, 432.0, string);
      }
      else
{
format(string, sizeof(string),"P:~g~ %d  ~w~L:~g~ %.1f  ~w~A:~g~ %.1f",killsvonplayer[i],lebenfloatvonplayer[i],armourfloatvonplayer[i]);
status_unten[i] = TextDrawCreate(0.0, 432.0, string);
      }
     
TextDrawLetterSize(status_unten[i], 0.3, 1.5);
TextDrawUseBox(status_unten[i], true);
TextDrawBoxColor(status_unten[i], 0x000000cc);
TextDrawShowForPlayer(i,status_unten[i]);
}
}
}

public OnGameModeExit()
{
KillTimer(textdrawtimer);
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
  SetPlayerInterior(playerid, 1);
SetPlayerPos(playerid, -784.8948,498.3206,1371.7422);
SetPlayerFacingAngle(playerid, 0.3642);
SetPlayerCameraPos(playerid, -784.8948,506.5578,1374.5422);
SetPlayerCameraLookAt(playerid, -784.8948,498.3206,1371.7422);

new info_string[255];
new request_string[255];

switch(classid)
{
  case 0:
  format(request_string, sizeof(request_string),"~g~Los Santos");
}

format(info_string, sizeof(info_string),"~w~Spawn: %s", request_string);
for (new i; i < MAX_PLAYERS; i++)
{
TextDrawDestroy(status_unten[i]);
}
status_unten[playerid] = TextDrawCreate(0.0, 432.0, info_string);
TextDrawLetterSize(status_unten[playerid], 0.3, 1.5);
TextDrawUseBox(status_unten[playerid], true);
TextDrawBoxColor(status_unten[playerid], 0x000000cc);
TextDrawShowForPlayer(playerid,status_unten[playerid]);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
for (new i; i < MAX_PLAYERS; i++)
{
TextDrawDestroy(status_unten[i]);
}
return 1;
}

public OnPlayerSpawn(playerid)
{
textdrawtimer = SetTimer("Anzeige",100,1);
return 1;
}
Why are you doing this

pawn Code:
public OnPlayerRequestClass(playerid, classid)
{
  SetPlayerInterior(playerid, 1);
SetPlayerPos(playerid, -784.8948,498.3206,1371.7422);
SetPlayerFacingAngle(playerid, 0.3642);
SetPlayerCameraPos(playerid, -784.8948,506.5578,1374.5422);
SetPlayerCameraLookAt(playerid, -784.8948,498.3206,1371.7422);

new info_string[255];
new request_string[255];

switch(classid)
{
  case 0:
  format(request_string, sizeof(request_string),"~g~Los Santos");
}

format(info_string, sizeof(info_string),"~w~Spawn: %s", request_string);
for (new i; i < MAX_PLAYERS; i++)
{
TextDrawDestroy(status_unten[i]);
}
status_unten[playerid] = TextDrawCreate(0.0, 432.0, info_string);
TextDrawLetterSize(status_unten[playerid], 0.3, 1.5);
TextDrawUseBox(status_unten[playerid], true);
TextDrawBoxColor(status_unten[playerid], 0x000000cc);
TextDrawShowForPlayer(playerid,status_unten[playerid]);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
for (new i; i < MAX_PLAYERS; i++)
{
TextDrawDestroy(status_unten[i]);
}
return 1;
}
everytime a player connects or disconnects it will destroy everyones textdraws ?


Re: [Textdraw] New Player steals the Textdraw - KingArthur - 27.02.2009

Quote:
Originally Posted by JaYmE
Why are you doing this
Because the two textdraws are on the same position, but has to show different things in OnPlayerRequestClass and Anzeige. I think i have to destroy the other textdraw to show the next one !?!? Or not?


Re: [Textdraw] New Player steals the Textdraw - JaYmE - 27.02.2009

but your destroying al the textdrawes not just the player that connected ?