SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/08/2019, 03:50 PM   #1
slxsh
Little Clucker
 
slxsh's Avatar
 
Join Date: Oct 2018
Posts: 25
Reputation: 0
Default TextDraws Keep Stacking

Basically I want to show gang name during class selection but right now whenever I switch through different classes, textdraws keep stacking. I tried using PlayerTextDrawHide but still same problem.
Code:
public OnPlayerRequestClass(playerid, classid)
{
	new members[5];
	new PlayerText:GangNameTextDraw = CreatePlayerTextDraw(playerid,300,140," ");
	new PlayerText:GangOnlineText = CreatePlayerTextDraw(playerid,265,377," ");
	switch(classid){
	    case 0,1,2:{
			SetPlayerCameraPos(playerid, -2011.6372, 256.9467, 39.7020);
			SetPlayerCameraLookAt(playerid, -2010.7859, 256.4149, 39.5366);
			SetPlayerPos(playerid,-1992.5592,242.9272,52.7569);
			format(members,sizeof(members),"Players Online : %d",GangInfo[GROVE][gMembers]);
    		PlayerTextDrawSetString(playerid,GangNameTextDraw,"GROVE");
    		PlayerTextDrawSetString(playerid,GangOnlineText,members);
    		PlayerTextDrawFont(playerid,GangNameTextDraw,3);
    		PlayerTextDrawLetterSize(playerid,GangNameTextDraw,0.8,3.2);
    		PlayerTextDrawSetOutline(playerid,GangNameTextDraw,1);
    		PlayerTextDrawColor(playerid,GangNameTextDraw,0x32CD32FF);
	  		PlayerTextDrawShow(playerid,GangNameTextDraw);
	  		PlayerTextDrawShow(playerid,GangOnlineText);
		} //grove hq
	}
	return 1;
}
When I click next class last textdraw is also there behind the new textdraw.
__________________
not an expert
slxsh is offline   Reply With Quote
Old 27/08/2019, 04:09 PM   #2
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 327
Reputation: 22
Default Re: TextDraws Keep Stacking

https://wiki.sa-mp.com/wiki/CreatePlayerTextDraw
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 27/08/2019, 04:32 PM   #3
slxsh
Little Clucker
 
slxsh's Avatar
 
Join Date: Oct 2018
Posts: 25
Reputation: 0
Default Re: TextDraws Keep Stacking

Quote:
Originally Posted by SiaReyes View Post
I know how to create TextDraws
__________________
not an expert
slxsh is offline   Reply With Quote
Old 27/08/2019, 07:34 PM   #4
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 284
Reputation: 38
Default Re: TextDraws Keep Stacking

Try this
Code:
new PlayerText:GangNameTextDraw,PlayerText:GangOnlineText;

public OnPlayerConnect(playerid)
{
    GangNameTextDraw = CreatePlayerTextDraw(playerid,300,140,"Loading...");
    PlayerTextDrawFont(playerid,GangNameTextDraw,3);
    PlayerTextDrawLetterSize(playerid,GangNameTextDraw,0.8,3.2);
    PlayerTextDrawSetOutline(playerid,GangNameTextDraw,1);
    PlayerTextDrawColor(playerid,GangNameTextDraw,0x32CD32FF);
	
    GangOnlineText = CreatePlayerTextDraw(playerid,265,377,"Loading...");
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    new members[20];
    switch(classid){
        case 0,1,2:{
            SetPlayerCameraPos(playerid, -2011.6372, 256.9467, 39.7020);
            SetPlayerCameraLookAt(playerid, -2010.7859, 256.4149, 39.5366);
            SetPlayerPos(playerid,-1992.5592,242.9272,52.7569);
            format(members,sizeof(members),"Players Online : %d",GangInfo[GROVE][gMembers]);
            PlayerTextDrawSetString(playerid,GangNameTextDraw,"GROVE");
            PlayerTextDrawSetString(playerid,GangOnlineText,members);
            PlayerTextDrawShow(playerid,GangNameTextDraw);
            PlayerTextDrawShow(playerid,GangOnlineText);
        } //grove hq
        case 1,2,3:{ //This is an example
            format(members,sizeof(members),"Players Online : %d",GangInfo[BALLAS][gMembers]);
            PlayerTextDrawSetString(playerid,GangNameTextDraw,"BALLAS");
            PlayerTextDrawSetString(playerid,GangOnlineText,members);
            PlayerTextDrawShow(playerid,GangNameTextDraw); //You just need to re-show textdraw, you don't need to hide it since it's the same textdraw
            PlayerTextDrawShow(playerid,GangOnlineText); //You just need to re-show textdraw, you don't need to hide it since it's the same textdraw
        } //ballas hq
    }
    return 1;
}
Most of the times i hate OnPlayerRequestClass because it doesn't even gets called, try to debug your OnPlayerRequestClass with a random print or SendClientMessage and if it acts like that you can put this under OnPlayerConnect:
Code:
CallLocalFunction("OnPlayerRequestClass", "ii", playerid, 0);
I hope this could solve your problems
__________________

Last edited by Jonny; 27/08/2019 at 07:37 PM. Reason: Identation fucked up in SA-MP forum...
Jonny is offline   Reply With Quote
Old 28/08/2019, 03:04 AM   #5
slxsh
Little Clucker
 
slxsh's Avatar
 
Join Date: Oct 2018
Posts: 25
Reputation: 0
Default Re: TextDraws Keep Stacking

Quote:
Originally Posted by darkdrago View Post
Try this
Code:
new PlayerText:GangNameTextDraw,PlayerText:GangOnlineText;

public OnPlayerConnect(playerid)
{
    GangNameTextDraw = CreatePlayerTextDraw(playerid,300,140,"Loading...");
    PlayerTextDrawFont(playerid,GangNameTextDraw,3);
    PlayerTextDrawLetterSize(playerid,GangNameTextDraw,0.8,3.2);
    PlayerTextDrawSetOutline(playerid,GangNameTextDraw,1);
    PlayerTextDrawColor(playerid,GangNameTextDraw,0x32CD32FF);
	
    GangOnlineText = CreatePlayerTextDraw(playerid,265,377,"Loading...");
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    new members[20];
    switch(classid){
        case 0,1,2:{
            SetPlayerCameraPos(playerid, -2011.6372, 256.9467, 39.7020);
            SetPlayerCameraLookAt(playerid, -2010.7859, 256.4149, 39.5366);
            SetPlayerPos(playerid,-1992.5592,242.9272,52.7569);
            format(members,sizeof(members),"Players Online : %d",GangInfo[GROVE][gMembers]);
            PlayerTextDrawSetString(playerid,GangNameTextDraw,"GROVE");
            PlayerTextDrawSetString(playerid,GangOnlineText,members);
            PlayerTextDrawShow(playerid,GangNameTextDraw);
            PlayerTextDrawShow(playerid,GangOnlineText);
        } //grove hq
        case 1,2,3:{ //This is an example
            format(members,sizeof(members),"Players Online : %d",GangInfo[BALLAS][gMembers]);
            PlayerTextDrawSetString(playerid,GangNameTextDraw,"BALLAS");
            PlayerTextDrawSetString(playerid,GangOnlineText,members);
            PlayerTextDrawShow(playerid,GangNameTextDraw); //You just need to re-show textdraw, you don't need to hide it since it's the same textdraw
            PlayerTextDrawShow(playerid,GangOnlineText); //You just need to re-show textdraw, you don't need to hide it since it's the same textdraw
        } //ballas hq
    }
    return 1;
}
Most of the times i hate OnPlayerRequestClass because it doesn't even gets called, try to debug your OnPlayerRequestClass with a random print or SendClientMessage and if it acts like that you can put this under OnPlayerConnect:
Code:
CallLocalFunction("OnPlayerRequestClass", "ii", playerid, 0);
I hope this could solve your problems
Problem Solved.
It was happening because I placed CreatePlayerTextDraw inside the OnPlayerRequestClass so whenever I clicked next in class selection a new textdraw was being created.
Thanks
__________________
not an expert
slxsh is offline   Reply With Quote
Old 29/08/2019, 06:03 PM   #6
GTLS
High-roller
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 1,044
Reputation: 115
Default Re: TextDraws Keep Stacking

May be just changed the String of a textdraw instead of creating of new one each time? You didnt have to show them each time you update their string. Otherwise it would stake.
__________________

I don't help for rep. I help cuz I was helped in the past.


Retired from SAMP Scene. Might open SAMP Forums once in a while.

Some treats for ya. Click em
Basic House System
Simple Speedo
Base Login/Register Script

GTLS is offline   Reply With Quote
Old 29/08/2019, 06:09 PM   #7
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 284
Reputation: 38
Default Re: TextDraws Keep Stacking

Quote:
Originally Posted by GTLS View Post
May be just changed the String of a textdraw instead of creating of new one each time? You didnt have to show them each time you update their string. Otherwise it would stake.
He already solved his problem and he actually doesn't creates a new one each time.
Sorry but why do you reply in a solved thread?
__________________
Jonny is offline   Reply With Quote
Old 29/08/2019, 06:15 PM   #8
GTLS
High-roller
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 1,044
Reputation: 115
Default Re: TextDraws Keep Stacking

Quote:
Originally Posted by darkdrago View Post
He already solved his problem and he actually doesn't creates a new one each time.
Sorry but why do you reply in a solved thread?
I meant show.. sorry about that. He is showing it at each step. What I meant is, show it OnRequestClass and update the string based on his selection. Otherwise its just code repetition.

Also, I reply cuz I can. There's no rule stating I cant.
__________________

I don't help for rep. I help cuz I was helped in the past.


Retired from SAMP Scene. Might open SAMP Forums once in a while.

Some treats for ya. Click em
Basic House System
Simple Speedo
Base Login/Register Script

GTLS is offline   Reply With Quote
Old 29/08/2019, 06:21 PM   #9
Jonny
Huge Clucker
 
Jonny's Avatar
 
Join Date: Nov 2009
Location: Italy
Posts: 284
Reputation: 38
Default Re: TextDraws Keep Stacking

Quote:
Originally Posted by GTLS View Post
I meant show.. sorry about that. He is showing it at each step. What I meant is, show it OnRequestClass and update the string based on his selection. Otherwise its just code repetition.

Also, I reply cuz I can. There's no rule stating I cant.
The only thing he could do is showing it outside of the switch, but since OnPlayerRequestClass gets called at each selection it's kinda the same result.

I didn't mean that you can't, but if he solved his problem you're just updating a thread that doesn't needs to be updated, also if there is more threads which are requesting help you're just pulling this up to them
__________________
Jonny is offline   Reply With Quote
Old 29/08/2019, 06:23 PM   #10
GTLS
High-roller
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 1,044
Reputation: 115
Default Re: TextDraws Keep Stacking

I just replied to make his code more better nothing else. Not everything is done because its "needed". Plus, people who are online to help will check through every thread not just the top ones. So.. We good
__________________

I don't help for rep. I help cuz I was helped in the past.


Retired from SAMP Scene. Might open SAMP Forums once in a while.

Some treats for ya. Click em
Basic House System
Simple Speedo
Base Login/Register Script

GTLS is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Global textdraws or player textdraws? Dreyfuz Scripting Help 3 08/08/2015 10:13 AM
Global TextDraws on top of Player TextDraws [resolved] Joe Staff Scripting Help 0 17/05/2013 06:35 AM
[BUG] Selecting textdraws lighting up multiple textdraws Hiddos Scripting Help 3 24/03/2012 03:44 PM
SQL String in Dialog/Stacking Dynamic Menu ISSUES Nacho_Bidnezz Scripting Help 1 25/01/2012 11:19 AM
[TEXTDRAWS] Textdraws mixed up KnooL Help Archive 22 23/06/2010 03:52 PM


All times are GMT. The time now is 08:05 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.