SA-MP Forums Archive
Textdraw Problem... - 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)
+--- Thread: Textdraw Problem... (/showthread.php?tid=611496)



Textdraw Problem... - nemanjasepa - 07.07.2016

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...
PHP код:
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;
} 
PHP код:
public OnGameModeInit()
{
    
DrugOnGameModeInit();
        ... 
PHP код:
public OnPlayerDisconnect(playerid,reason)
{
DrugOnPlayerDisconnect(playerid,reason); 
This is showing when player spawn...


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


Re: Textdraw Problem... - luke49 - 07.07.2016

If you want to show this textdraw when player writes /usedrugs, then use TextDrawShowForPlayer function inside /usedrugs command, not when player spawns.


Re: Textdraw Problem... - nemanjasepa - 07.07.2016

But I didn't used it inside OnPlayerSpawn


Re: Textdraw Problem... - luke49 - 07.07.2016

Then where do you use TextDrawShowForPlayer?


Re: Textdraw Problem... - nemanjasepa - 07.07.2016

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


Re: Textdraw Problem... - luke49 - 07.07.2016

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.