[Textdraw] New Player steals the Textdraw
#1

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.

...
Reply
#2

I cant understand you sorry

Can you explain what you trying to do with it?
Reply
#3

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

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?!
Reply
#5

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?
Reply
#6

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.
Reply
#7

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"?
Reply
#8

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 ?
Reply
#9

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?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)