Textdraw mess -_- -
Killer#Mummy - 17.07.2010
Hi everyone! I have little problem with my textdraws.
First, I make new variables:
Код:
new Text:MessageTitle[MAX_PLAYERS];
new Text:MessageText[MAX_PLAYERS];
new Text:WorldCountTextDraw;
Then I make the textdraws:
Код:
for(new PlayerNumber;PlayerNumber > MAX_PLAYERS;PlayerNumber++)
{
MessageTitle[PlayerNumber] = TextDrawCreate(93.0,100.0," ");
TextDrawAlignment(MessageTitle[PlayerNumber],2);
TextDrawBackgroundColor(MessageTitle[PlayerNumber],255);
TextDrawFont(MessageTitle[PlayerNumber],3);
TextDrawLetterSize(MessageTitle[PlayerNumber],0.309998,1.199998);
TextDrawSetProportional(MessageTitle[PlayerNumber],1);
TextDrawSetShadow(MessageTitle[PlayerNumber],1);
TextDrawUseBox(MessageTitle[PlayerNumber],1);
TextDrawBoxColor(MessageTitle[PlayerNumber],150);
TextDrawTextSize(MessageTitle[PlayerNumber],0.0,149.0);
MessageText[PlayerNumber] = TextDrawCreate(93.0,120.0," ");
TextDrawAlignment(MessageText[PlayerNumber],2);
TextDrawBackgroundColor(MessageText[PlayerNumber],150);
TextDrawFont(MessageText[PlayerNumber],1);
TextDrawLetterSize(MessageText[PlayerNumber],0.209999,0.899999);
TextDrawColor(MessageText[PlayerNumber],-1);
TextDrawSetProportional(MessageText[PlayerNumber],1);
TextDrawSetShadow(MessageText[PlayerNumber],1);
TextDrawUseBox(MessageText[PlayerNumber],1);
TextDrawBoxColor(MessageText[PlayerNumber],0);
TextDrawTextSize(MessageText[PlayerNumber],0.0,149.0);
}
WorldCountTextDraw = TextDrawCreate(99.0,437.0,"~g~Deathmatch~w~: 0 ~y~Freeroam~w~: 0 ~r~Stunt~w~: 0");
TextDrawAlignment(WorldCountTextDraw,2);
TextDrawBackgroundColor(WorldCountTextDraw,255);
TextDrawFont(WorldCountTextDraw,1);
TextDrawLetterSize(WorldCountTextDraw,0.3,1.1);
TextDrawColor(WorldCountTextDraw,-1);
TextDrawSetProportional(WorldCountTextDraw,1);
TextDrawSetShadow(WorldCountTextDraw,1);
TextDrawUseBox(WorldCountTextDraw,1);
TextDrawBoxColor(WorldCountTextDraw,175);
TextDrawTextSize(WorldCountTextDraw,0.0,196.0);
Then I make one function which includes textdraws:
Код:
public PlayerChangeWorld(playerid,WorldID)
{
PlayerPlaySound(playerid,1188,0,0,0);
WorldCount[WorldID]++; WorldCount[Player[playerid][World]]--;
Player[playerid][World] = WorldID;
Player[playerid][SpeedBoost] = false; Player[playerid][Hopping] = false; Player[playerid][AutoFix] = false;
Player[playerid][Mission] = false;
SetPlayerVirtualWorld(playerid,WorldID);
if(WorldID == WORLD_SPAWN)
{
SetPlayerPos(playerid,6689.2803,3211.4292,17.9470);
SetPlayerFacingAngle(playerid,5.9533);
StreamOn(playerid);
PlayerPlaySound(playerid,1187,0,0,0);
}
if(WorldID == WORLD_FREEROAM)
{
new PlayerName[24]; GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
format(String,sizeof(String),"[World] Player %s has gone to Freeroam World.",PlayerName);
SendClientMessageToAllEx(playerid,COLOR_YELLOW,String);
}
if(WorldID == WORLD_STUNT)
{
new Random = random(MAX_MAPS);
if(Map[Random][World] == WORLD_STUNT)
{
new PlayerName[24]; GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
format(String,sizeof(String),"[World] Player %s has gone to Stunt World.",PlayerName);
SendClientMessageToAllEx(playerid,COLOR_YELLOW,String);
Player[playerid][SpeedBoost] = true; Player[playerid][Hopping] = true; Player[playerid][AutoFix] = true;
TeleportPlayer(playerid,Map[Random][Name]);
}
else
{
return PlayerChangeWorld(playerid,WORLD_STUNT);
}
}
format(String,sizeof(String),"~g~Deathmatch~w~: %d ~y~Freeroam~w~: %d ~r~Stunt~w~: %d",WorldCount[1],WorldCount[2],WorldCount[3]);
TextDrawSetString(WorldCountTextDraw,String);
return 1;
}
And then I have two little functions for showing messages and it includes textdraws too:
Код:
public ShowMessage(playerid,Title[],Text1[],Time)
{
KillTimer(PlayerMessageTimer[playerid]);
Player[playerid][Message] = true;
PlayerPlaySound(playerid,1085,0,0,0);
TextDrawSetString(MessageTitle[playerid],Title);
TextDrawSetString(MessageText[playerid],Text1);
TextDrawShowForPlayer(playerid,MessageTitle[playerid]);
TextDrawShowForPlayer(playerid,MessageText[playerid]);
if(Time) return PlayerMessageTimer[playerid] = SetTimerEx("HideMessage",Time * 1000,0,"%d",playerid);
return 1;
}
public HideMessage(playerid)
{
Player[playerid][Message] = false;
TextDrawHideForPlayer(playerid,MessageTitle[playerid]);
TextDrawHideForPlayer(playerid,MessageText[playerid]);
KillTimer(PlayerMessageTimer[playerid]);
return 1;
}
The problem is, that when the player recieve message via ShowMessage(....), the text he recieve appears on WorldCount textdraw.
I dont know how to fix this, so I ask you if you can help me. Thanks.
Re: Textdraw mess -_- -
Vince - 17.07.2010
This
pawn Код:
for(new PlayerNumber;PlayerNumber > MAX_PLAYERS;PlayerNumber++)
should be
pawn Код:
for(new PlayerNumber;PlayerNumber < MAX_PLAYERS;PlayerNumber++)
Re: Textdraw mess -_- -
Betamaster - 17.07.2010
Please use pastebin for posting large portions of code.
You need to learn to debug your code. You can easily do this by using print and printf.
eg. to check what values MessageTitle[playerid] and MessageText[playerid] are...
pawn Код:
printf("MessageTitle[%d]=%d MessageText[%d]=%d", playerid, _:MessageTitle[playerid], playerid, _:MessageText[playerid]);
Now go back and recheck your code and use some print statements. At the very least, recheck your first line of code.