SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/01/2020, 10:26 AM   #1
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default newline GameTextForPlayer not work

why no one second line is working on this GameTextForPlayer?

Code:
    new str[128], final[512];
    format(str, sizeof(str), "~y~mission passed!~n~");
    strcat(final, str);
    if(reward_exp > 0) {
        format(str, sizeof(str), "~w~+%i exp ", reward_exp);
        strcat(final, str);
    }
    if(reward_criminal > 0) {
        format(str, sizeof(str), "~w~+%i criminal ", reward_criminal);
        strcat(final, str);
    }
    if(reward_cop > 0) {
        format(str, sizeof(str), "~w~+%i cop ", reward_cop);
        strcat(final, str);
    }
    if(reward_money > 0) {
        format(str, sizeof(str), "~w~+%i$ ", reward_money);
        strcat(final, str);
    }
    GameTextForPlayer(playerid,final, 3000, 3);
the first line format(str, sizeof(str), "~y~mission passed!~n~");
the next ones no one is working
why?
binnyl is offline   Reply With Quote
Old 02/01/2020, 12:33 PM   #2
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 637
Reputation: 64
Default Re: newline GameTextForPlayer not work

Do you mean each line should be on new line? then you have to insert '~n~' on the end of every line
Edit: btw your variables' size is larger
__________________
coool is online now   Reply With Quote
Old 02/01/2020, 12:36 PM   #3
YouShootIDodge
Big Clucker
 
Join Date: May 2019
Posts: 77
Reputation: 15
Default Re: newline GameTextForPlayer not work

Code:
    new str[128], final[512];
    format(str, sizeof(str), "~y~mission passed!~n~");
    strcat(final, str);
    if(reward_exp > 0) {
        format(str, sizeof(str), "~w~+%i exp~n~", reward_exp);
        strcat(final, str);
    }
    if(reward_criminal > 0) {
        format(str, sizeof(str), "~w~+%i criminal~n~", reward_criminal);
        strcat(final, str);
    }
    if(reward_cop > 0) {
        format(str, sizeof(str), "~w~+%i cop~n~", reward_cop);
        strcat(final, str);
    }
    if(reward_money > 0) {
        format(str, sizeof(str), "~w~+%i$~n~", reward_money);
        strcat(final, str);
    }
    GameTextForPlayer(playerid,final, 3000, 3);
YouShootIDodge is offline   Reply With Quote
Old 02/01/2020, 02:06 PM   #4
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: newline GameTextForPlayer not work

I did ~n~in the end of the first one, and a space in the end of every second one, cause i want
Code:
~w~+%i exp, ~w~+%i criminal
in the same line
binnyl is offline   Reply With Quote
Old 02/01/2020, 02:16 PM   #5
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 36
Reputation: 11
Default Re: newline GameTextForPlayer not work

Quote:
Originally Posted by binnyl View Post
I did ~n~in the end of the first one, and a space in the end of every second one, cause i want
Code:
~w~+%i exp, ~w~+%i criminal
in the same line
u mean like this?

PHP Code:
    new str[128], final[512];
    
format(strsizeof(str), "~y~mission passed!~n~");
    
strcat(final, str);
    if(
reward_exp 0) {
        
format(strsizeof(str), "~w~+%i exp,"reward_exp);
        
strcat(final, str);
    }
    if(
reward_criminal 0) {
        
format(strsizeof(str), "~w~+%i criminal~n~"reward_criminal);
        
strcat(final, str);
    }
    if(
reward_cop 0) {
        
format(strsizeof(str), "~w~+%i cop~n~"reward_cop);
        
strcat(final, str);
    }
    if(
reward_money 0) {
        
format(strsizeof(str), "~w~+%i$~n~"reward_money);
        
strcat(final, str);
    }
    
GameTextForPlayer(playerid,final, 30003); 

btw here these 2 lines are going to pop up under the first 2 lines. (because of ~n~)
PHP Code:
/*   if(reward_cop > 0) {
        format(str, sizeof(str), "~w~+%i cop~n~", reward_cop);
        strcat(final, str);
    }
    if(reward_money > 0) {
        format(str, sizeof(str), "~w~+%i$~n~", reward_money);
        strcat(final, str);
    }*/ 
__________________
Discord: Flofey#8478
Flofey is offline   Reply With Quote
Old 02/01/2020, 04:07 PM   #6
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: newline GameTextForPlayer not work

Quote:
Originally Posted by Flofey View Post
u mean like this?

PHP Code:
    new str[128], final[512];
    
format(strsizeof(str), "~y~mission passed!~n~");
    
strcat(final, str);
    if(
reward_exp 0) {
        
format(strsizeof(str), "~w~+%i exp,"reward_exp);
        
strcat(final, str);
    }
    if(
reward_criminal 0) {
        
format(strsizeof(str), "~w~+%i criminal~n~"reward_criminal);
        
strcat(final, str);
    }
    if(
reward_cop 0) {
        
format(strsizeof(str), "~w~+%i cop~n~"reward_cop);
        
strcat(final, str);
    }
    if(
reward_money 0) {
        
format(strsizeof(str), "~w~+%i$~n~"reward_money);
        
strcat(final, str);
    }
    
GameTextForPlayer(playerid,final, 30003); 

btw here these 2 lines are going to pop up under the first 2 lines. (because of ~n~)
PHP Code:
/*   if(reward_cop > 0) {
        format(str, sizeof(str), "~w~+%i cop~n~", reward_cop);
        strcat(final, str);
    }
    if(reward_money > 0) {
        format(str, sizeof(str), "~w~+%i$~n~", reward_money);
        strcat(final, str);
    }*/ 
The code u post is exactly like mine but u put a ~n~ creating 5 lines instead of 2

i want this:
Mission Passed!
+30 exp +20 criminal +5 cop +300000$

just like i tried to do

the problem is this second line: +30 exp +20 criminal +5 cop +300000$
is not showing and idk why
binnyl is offline   Reply With Quote
Old 02/01/2020, 04:55 PM   #7
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 36
Reputation: 11
Default Re: newline GameTextForPlayer not work

Quote:
Originally Posted by binnyl View Post
The code u post is exactly like mine but u put a ~n~ creating 5 lines instead of 2

i want this:
Mission Passed!
+30 exp +20 criminal +5 cop +300000$

just like i tried to do

the problem is this second line: +30 exp +20 criminal +5 cop +300000$
is not showing and idk why
had to test it to make it work,

try this now

PHP Code:
        if(reward_exp && reward_criminal && reward_cop && reward_money 0)
        {
        
format(str2sizeof(str2), "~y~mission passed!~n~ ~w~+%i exp, ~w~+%i criminal, ~w~+%i cop, ~w~+%i$"reward_exp reward_criminalreward_copreward_money);
        
strcat(final, str);
        
GameTextForPlayer(playerid,final, 30003);
        } 
__________________
Discord: Flofey#8478
Flofey 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
DOF2 and NewLine - Help me Please [XPG]MarlonCS Scripting Help 3 26/10/2014 08:15 PM
GameTextForPlayer Doesn't work :/ anantanni Help Archive 5 15/04/2011 08:22 PM
GameTextForPlayer doesn`t Work Manuel20 Help Archive 17 02/04/2010 03:13 PM
\n - newline doesnt work? :S Baff Help Archive 4 08/10/2009 06:21 PM


All times are GMT. The time now is 09:19 AM.


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