Talking TextDraw
#1

Hi, for my server I want to make something like in GTA SA singleplayer
when doing a mission there will be a little textdraw with a conversation between everyone who is in the car...
I have asked some help in script request and stuff but it just does not work...
ok so my code:
pawn Код:
new Text:talking;
pawn Код:
talking = TextDrawCreate(186, 406, " ");
    TextDrawFont(talking, 1);
    TextDrawSetShadow(talking,0);
    TextDrawSetOutline(talking,1);
    TextDrawTextSize(talking, 2.0, 3.0);
pawn Код:
TextDrawShowForPlayer(playerid,talking);
(under OnPlayerConnect)

pawn Код:
jobtalk(playerid);
function that I made
I put it here:
pawn Код:
if(IsPlayerInDynamicCP(playerid, TRAVJ1))
    {
        if(IsWorking[playerid] != 1)
        {
            SendClientMessage(playerid, COLOR_RED, "This is used in a drivers mission");
            return 1;
        }

        if(vehicle != 516)
        {
            SendClientMessage(playerid,COLOR_RED,"You are not in the right vehicle for this mission!");
            return 1;
        }

            TogglePlayerDynamicCP(playerid, TRAVJ1, false);
            TogglePlayerDynamicCP(playerid, TRAVJ2, true);

            SendClientMessage(playerid, COLOR_YELLOW, "Step 1/2");
            //RemovePlayerMapIcon( playerid, 2 );
            //SetPlayerMapIcon( playerid, 2, 2732.6616,-1841.6346,9.9145, 41, 0, MAPICON_GLOBAL );
            //Talk function
            jobtalk(playerid);
            return 1;
    }
this CP will be toggled when a player enters the first CP

pawn Код:
jobtalk(playerid)
{
    SetTimerEx("SumTimer",10000,1,"i",playerid);
}
pawn Код:
public SumTimer(playerid)
{
    TimeValue++;
   
    if(Job[playerid] == Travis)
    {
        switch(TimeValue)
        {
                case 0: TextDrawSetString(talking,"*Travis: Hi I'm Travis Pastrana, You're my driver, right?");
                case 1: TextDrawSetString(talking,"*You: Yes that's correct, I'm your driver for today!");
                case 2: TextDrawSetString(talking,"*Travis: Ok, nice to meet you, I hope you bring safe to the stadium");
                case 3: TextDrawSetString(talking,"*You: I ensure you, I'm the best driver in town!");
                case 4: TextDrawSetString(talking,"*Travis: Haha ok, then mate");
                case 5: TextDrawSetString(talking,"*You: lol");
                case 6: TextDrawSetString(talking,"*you: So tell me Travis, are you nervous for tonight?");
                case 7: TextDrawSetString(talking,"*Travis: yes, I'm kinda nervous, it's a really big deal you know...");
                case 8: TextDrawSetString(talking,"*You: Yeah, tell me what...");
                case 9: TextDrawSetString(talking,"*Travis: You drive motorcycles too??");
                case 10: TextDrawSetString(talking,"*You: Me??? No, only Nebula's and my wife...");
                case 11: TextDrawSetString(talking,"*Travis: Eww -.-");
                case 12: TextDrawSetString(talking,"*You: Oh, Excuse me, inapropriate?");
                case 13: TextDrawSetString(talking,"*Travis: Nono, it's ok mate");
                case 14: TextDrawSetString(talking,"*You: Ok then");
                case 15: TextDrawSetString(talking,"*You: 'dumdum, dumdum'");
                case 16: TextDrawSetString(talking,"*Travis: What's wrong?");
                case 17: TextDrawSetString(talking,"*You: Wrong? oh, nothings wrong! I just got this new maddog song in ma head dawg");
                case 18: TextDrawSetString(talking,"*Travis: Meh, I don't really like Rap songs, I find them too inapropriate");
        }
    }
    else if(Job[playerid] == Burger)
    {
        switch(TimeValue)
            {
                case 0: TextDrawSetString(talking,"*Server owner: You, there little slave, bring me a burger! now!");
                case 1: TextDrawSetString(talking,"*You: Omg, why so rude!!!");
                case 2: TextDrawSetString(talking,"*Server owner: Oh, excuse me, you thought I was nice? You thought the server owner was nice!");
                case 3: TextDrawSetString(talking,"*Server owner: No!! the server owner has powers, and of course I missuse them!");
                case 4: TextDrawSetString(talking,"*You: Wow, little prick!");
                case 5: TextDrawSetString(talking,"*Server owner: Wanna get banned? is that what cha want?");
                case 6: TextDrawSetString(talking,"*You: Okok I'm sorry *whisper* stupid asshole*");
                case 7: TextDrawSetString(talking,"*Server owner: What did u say?");
                case 8: TextDrawSetString(talking,"*You: Euhm, I said I'm sorry");
                case 9: TextDrawSetString(talking,"*Server owner: Good now, go get my goddamn burger!");
                case 10: TextDrawSetString(talking,"*You: dumdumdidumdum! dumdumdadum");
                case 11: TextDrawSetString(talking,"*Server owner: Are you singing");
                case 12: TextDrawSetString(talking,"*You: Yes its the new maddog!");
                case 13: TextDrawSetString(talking,"*Server owner: Stop it! I hate singing");
                case 14: TextDrawSetString(talking,"*You: -.-");
                case 15: TextDrawSetString(talking,"*You: -.-");
                case 16: TextDrawSetString(talking,"* : What's wrong?");
                case 17: TextDrawSetString(talking,"*You: Wrong? oh, nothings wrong! I just got this new maddog song in ma head dawg");
                case 18: TextDrawSetString(talking,"*Travis: Meh, I don't really like Rap songs, I find them too inapropriate");
            }
    }
    return 1;
}
Made 2 conversations so far...
I get no errors, but when I enter CP 2 I get the messages of the CP but the jobtalk just does not start :/ any help?

plus rep for helper ofc
Reply
#2

i think u need more work for this like timers and lots of new forwards for each message but who knows i may be wrong xD
Reply
#3

I think you are putting that function you made under OnPlayerConnect and it has "IsPlayerInDynamicCP". The player isn't in a checkpoint when he joins the server so it is returning false and the jobtalk function is never being called.
Reply
#4

1: It's called in this callback: public OnPlayerEnterDynamicCP(playerid, checkpointid)
2: how can the messages from the checkpoint be called if the CP hasn't even been entered...
Reply
#5

That code is vague but the most superlative logic errors I'm noticing are that SetTimerEx is being called with an integral 1 as a boolean value where true may have needed to be passed. I do not know if Pawn is picky but you should pass true to be safe. This timer will increment the TimeValue variable that I am not seeing in local or global scope for the player. The timer will theoretically increment this variable on into infamy if the timer repetitions argument is called as true as previously suggested. I suggest you change it to false to only call the timer once for the player then run a condition in the jobtalk function to determine whether or not to call the timer again from within itself or not based upon the value of TimeValue and the conversation.
Reply
#6

Quote:
Originally Posted by knackworst
Посмотреть сообщение
pawn Код:
public SumTimer(playerid)
{
    TimeValue++;
   
    if(Job[playerid] == Travis)
    {
        switch(TimeValue)
        {
                case 0: TextDrawSetString(talking,"*Travis: Hi I'm Travis Pastrana, You're my driver, right?");
                case 1: TextDrawSetString(talking,"*You: Yes that's correct, I'm your driver for today!");
                case 2: TextDrawSetString(talking,"*Travis: Ok, nice to meet you, I hope you bring safe to the stadium");
                case 3: TextDrawSetString(talking,"*You: I ensure you, I'm the best driver in town!");
                case 4: TextDrawSetString(talking,"*Travis: Haha ok, then mate");
                case 5: TextDrawSetString(talking,"*You: lol");
                case 6: TextDrawSetString(talking,"*you: So tell me Travis, are you nervous for tonight?");
                case 7: TextDrawSetString(talking,"*Travis: yes, I'm kinda nervous, it's a really big deal you know...");
                case 8: TextDrawSetString(talking,"*You: Yeah, tell me what...");
                case 9: TextDrawSetString(talking,"*Travis: You drive motorcycles too??");
                case 10: TextDrawSetString(talking,"*You: Me??? No, only Nebula's and my wife...");
                case 11: TextDrawSetString(talking,"*Travis: Eww -.-");
                case 12: TextDrawSetString(talking,"*You: Oh, Excuse me, inapropriate?");
                case 13: TextDrawSetString(talking,"*Travis: Nono, it's ok mate");
                case 14: TextDrawSetString(talking,"*You: Ok then");
                case 15: TextDrawSetString(talking,"*You: 'dumdum, dumdum'");
                case 16: TextDrawSetString(talking,"*Travis: What's wrong?");
                case 17: TextDrawSetString(talking,"*You: Wrong? oh, nothings wrong! I just got this new maddog song in ma head dawg");
                case 18: TextDrawSetString(talking,"*Travis: Meh, I don't really like Rap songs, I find them too inapropriate");
        }
    }
    else if(Job[playerid] == Burger)
    {
        switch(TimeValue)
            {
                case 0: TextDrawSetString(talking,"*Server owner: You, there little slave, bring me a burger! now!");
                case 1: TextDrawSetString(talking,"*You: Omg, why so rude!!!");
                case 2: TextDrawSetString(talking,"*Server owner: Oh, excuse me, you thought I was nice? You thought the server owner was nice!");
                case 3: TextDrawSetString(talking,"*Server owner: No!! the server owner has powers, and of course I missuse them!");
                case 4: TextDrawSetString(talking,"*You: Wow, little prick!");
                case 5: TextDrawSetString(talking,"*Server owner: Wanna get banned? is that what cha want?");
                case 6: TextDrawSetString(talking,"*You: Okok I'm sorry *whisper* stupid asshole*");
                case 7: TextDrawSetString(talking,"*Server owner: What did u say?");
                case 8: TextDrawSetString(talking,"*You: Euhm, I said I'm sorry");
                case 9: TextDrawSetString(talking,"*Server owner: Good now, go get my goddamn burger!");
                case 10: TextDrawSetString(talking,"*You: dumdumdidumdum! dumdumdadum");
                case 11: TextDrawSetString(talking,"*Server owner: Are you singing");
                case 12: TextDrawSetString(talking,"*You: Yes its the new maddog!");
                case 13: TextDrawSetString(talking,"*Server owner: Stop it! I hate singing");
                case 14: TextDrawSetString(talking,"*You: -.-");
                case 15: TextDrawSetString(talking,"*You: -.-");
                case 16: TextDrawSetString(talking,"* : What's wrong?");
                case 17: TextDrawSetString(talking,"*You: Wrong? oh, nothings wrong! I just got this new maddog song in ma head dawg");
                case 18: TextDrawSetString(talking,"*Travis: Meh, I don't really like Rap songs, I find them too inapropriate");
            }
    }
    return 1;
}

Case 0 won't be called. you need to do TimeValue++; at the end, or set it to -1 before you call that.
Reply
#7

oh i see, thanks
but still if only case 0: is not displayed, case 1, 2 ,3, etc should be displayed right?
but they do not display...
Reply
#8

Quote:
Originally Posted by knackworst
Посмотреть сообщение
this CP will be toggled when a player enters the first CP

pawn Код:
jobtalk(playerid)
{
    SetTimerEx("SumTimer",10000,1,"i",playerid);
}
pawn Код:
SetTimerEx("SumTimer",10000,true,"i",playerid);
Don't know if that change anything since its a boolean but thats how it is in wiki... sry gtg sleep.

pawn Код:
jobtalk(playerid)
{    
         SetTimerEx("SumTimer",10000,true,"i",playerid);
         return 1;
}
Also IDK but maybe...
Reply
#9

it means that every 10 seconds there will be a new sentence in the conversation ...
Reply
#10

Quote:
Originally Posted by knackworst
it means that every 10 seconds there will be a new sentence in the conversation ...
Thats not what he was stating, he was stating that the third parameter of SetTimerEx should be a boolean and that the integral value 1 might not be treated as true in that function and it may contort the validity of the function call

I already stated that that value should be false as it represents whether or not the function should be called repeatedly at the timer interval. Sorry to patronize you but as your posts would predicate your not at full understanding of the functions your using in your code. You need to create a condition in your function to designate whether or not to call the function again at that interval.

pawn Код:
if (TimeVal < 19)
     {
          SetTimerEx("SumTimer",10000,false,"i",playerid)
     }
if you don't do this that timer will run for as long as the server is running and you might proliferate your script with too many timers should they not be terminated and you have many players. I'm also not sure how the switch statement will manage values not fitting the cases 0 through 18 for each conversation without a default case.

PS: I don't know why your returning 1 in the jobtalk function and the timer handler, neither is necessary
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)