PDA

View Full Version : Textdraw Problem...


nemanjasepa
07/07/2016, 09:49 AM
I am using drug system for my gamemode, but I have one problem... Every time player connect to server, he will see textdraw.. I want player only to see textdraw when he use /usedrugs...
Here is code...

new Text: DrugText;
new AllColors[10][1] = {
{0xFFFF00AA},
{0xFF0000AA},
{0x0000FFAA},
{0xFF8C00AA},
{0x228B22AA},
{0xFF4500AA},
{0x8B4513AA},
{0x708090AA},
{0xFF6347AA},
{0xEE82EEAA}
};
new DrugEffectTimer[MAX_PLAYERS];
forward DrugColorChange(playerid);
forward DrugOnGameModeInit();
forward DrugOnGameModeExit(playerid);
forward DrugOnPlayerDisconnect(playerid,reason);
public DrugOnGameModeInit()
{
DrugText = TextDrawCreate(642.000000, 2.000000, "New Textdraw");
TextDrawBackgroundColor(DrugText, 255);
TextDrawFont(DrugText, 1);
TextDrawLetterSize(DrugText, 1.000000, 26.800003);
TextDrawSetOutline(DrugText, 0);
TextDrawSetProportional(DrugText, 1);
TextDrawSetShadow(DrugText, 1);
TextDrawUseBox(DrugText, 1);
TextDrawBoxColor(DrugText, 503316610);
TextDrawTextSize(DrugText, -2.000000, 0.000000);
return 1;
}
public DrugOnGameModeExit(playerid)
{
KillTimer(DrugEffectTimer[playerid]);
TextDrawHideForAll(DrugText);
TextDrawDestroy(DrugText);
return 1;
}
public DrugColorChange(playerid)
{
new randomize=random(sizeof(AllColors));
TextDrawBoxColor(DrugText, AllColors[randomize][0]);
TextDrawShowForPlayer(playerid,DrugText);
return 1;
}
public DrugOnPlayerDisconnect(playerid,reason)
{
KillTimer(DrugEffectTimer[playerid]);
return 1;
}



public OnGameModeInit()
{
DrugOnGameModeInit();
...



public OnPlayerDisconnect(playerid,reason)
{
DrugOnPlayerDisconnect(playerid,reason);


This is showing when player spawn...
http://i.imgur.com/FGbHTIk.png

I don't know how to fix this...

luke49
07/07/2016, 09:59 AM
If you want to show this textdraw when player writes /usedrugs, then use TextDrawShowForPlayer function inside /usedrugs command, not when player spawns.

nemanjasepa
07/07/2016, 10:02 AM
But I didn't used it inside OnPlayerSpawn

luke49
07/07/2016, 11:29 AM
Then where do you use TextDrawShowForPlayer?

nemanjasepa
07/07/2016, 11:48 AM
Only at DrugColorChange... You have in code above...
And also at /usedrugs command
DrugEffectTimer[playerid] = SetTimerEx("DrugColorChange",100,true,"d",playerid);

luke49
07/07/2016, 12:26 PM
Why do you create DrugEffectTimer variable? Do you put that timer only in the /usedrugs command?
Show me your OnPlayerSpawn, OnPlayerConnect and your /usedrugs command.