SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 01/05/2019, 03:31 AM   #1
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 274
Reputation: 2
Default Help me

I want to do SendClientMessage (new) instead of \n

PHP Code:
enum E_TUTORIAL_DATA {  
  
Float:tutorialCameraPosX,  
  
Float:tutorialCameraPosY,  
  
Float:tutorialCameraPosZ

  
Float:tutorialCameraDirX,  
  
Float:tutorialCameraDirY,  
  
Float:tutorialCameraDirZ

  
tutorialMessage[144+1],  
   
  
tutorialInterval  
}  

new 
TutorialData[][E_TUTORIAL_DATA] = {  

  { 
    
154.9954,-1950.3726,70.9366,
    
0.00000.00000.0000
    
"Welcome to "ServerName". This is a roleplay server, which means that you take on.\n\
    a role and play a character. Be it a crook, an officer of the law or just a regular citizen.\n\
    We refer to this as OOC (out of character) and IC (in character). This is something\n\
    that is an essential part of the server, therefore we keep them separate."
60 
  
}, 

  { 
    
1788.3181,-1883.9274,45.4654,
    
0.00000.00000.0000
    
"There are many ways to earn money and there are many jobs available throughout\n\
    the city. We recommend that you try Train Driver or Taxi Driver Job first to earn some\n\
    starting cash. You can find a job with the ~r~/findjob ~w~command.\n\
    You can also use the ~r~/jobhelp ~w~command to get more information about the jobs.\n\
    You can ~r~/withdraw ~w~and ~r~/deposit ~w~at the bank whenever you wish."
60 
  
},

  { 
    
1504.6958,-1712.0825,34.0079
    
1553.6398,-1681.3484,49.0423
    
"There are several law enforcement agencies such as the ~b~SAPD ~w~and the ~b~FBI~w~, who enforce\n\
    the law. They will arrest you if you break the law. If you cause a lot of trouble then\n\
    you could be marked as one of the most wanted suspects. Which will mark you ~r~red\n\
    on the radar/map. If you're caught as the most wanted suspect, then you will be\n\
    sent to prison for 30 minutes. If you can't do the time, then don't do the crime.\n\
    You can also join these factions. Just contact them in-game (blue names)."
60 
  
}  
}; 
PHP Code:
"There are several law enforcement agencies such as the ~b~SAPD ~w~and the ~b~FBI~w~, who enforce\n\
    the law. They will arrest you if you break the law. If you cause a lot of trouble then\n\
    you could be marked as one of the most wanted suspects. Which will mark you ~r~red\n\
    on the radar/map. If you're caught as the most wanted suspect, then you will be\n\
    sent to prison for 30 minutes. If you can't do the time, then don't do the crime.\n\
    You can also join these factions. Just contact them in-game (blue names)."

means when I do TutorialData[i][text], it will show the following lines and will send New SendClientMessage instead of \n or \n\
__________________
-

Akib Khan#4244
akib is offline   Reply With Quote
Old 01/05/2019, 03:35 AM   #2
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 274
Reputation: 2
Default Re: Help me

Ex:
PHP Code:
SendClientMessage(playerid,-1,"There are several law enforcement agencies such as the ~b~SAPD ~w~and the ~b~FBI~w~, who enforce");
SendClientMessage(playerid,-1,"the law. They will arrest you if you break the law. If you cause a lot of trouble then");
... 
__________________
-

Akib Khan#4244
akib is offline   Reply With Quote
Old 01/05/2019, 12:02 PM   #3
cSharp
Big Clucker
 
Join Date: Oct 2018
Posts: 82
Reputation: 27
Default Re: Help me

I'm not entirely sure but something like this I believe?

PHP Code:
new oldMessage[144+1];
strcat(oldMessageTutorialData[index][tutorialMessage]);

for(new 
0strlen(oldMessage); i++) {
  if(
oldMessage[i] == '\0')
    break;

  if(
oldMessage[i] != '\n')
    continue;

  new 
newMessage[144+1];

  
strdel(oldMessage0strmid(newMessageoldMessage0i+1sizeof newMessage));

  
0;

cSharp is offline   Reply With Quote
Old 01/05/2019, 02:01 PM   #4
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 274
Reputation: 2
Default Re: Help me

Quote:
Originally Posted by cSharp View Post
I'm not entirely sure but something like this I believe?

PHP Code:
new oldMessage[144+1];
strcat(oldMessageTutorialData[index][tutorialMessage]);

for(new 
0strlen(oldMessage); i++) {
  if(
oldMessage[i] == '\0')
    break;

  if(
oldMessage[i] != '\n')
    continue;

  new 
newMessage[144+1];

  
strdel(oldMessage0strmid(newMessageoldMessage0i+1sizeof newMessage));

  
0;

Usage? examples?
__________________
-

Akib Khan#4244
akib is offline   Reply With Quote
Old 01/05/2019, 03:48 PM   #5
cSharp
Big Clucker
 
Join Date: Oct 2018
Posts: 82
Reputation: 27
Default Re: Help me

Of what?... that's literally what you asked for.
cSharp is offline   Reply With Quote
Old 01/05/2019, 05:58 PM   #6
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 274
Reputation: 2
Default Re: Help me

Quote:
Originally Posted by cSharp View Post
Of what?... that's literally what you asked for.

I want to send client message instead of \n

\n = new line?
so new line will be displayed as a send client message

if there is 9 \n, there should be 9 SendClientMessage

Can you give me your discord? so i can explain you further more
__________________
-

Akib Khan#4244
akib is offline   Reply With Quote
Old 01/05/2019, 09:26 PM   #7
cSharp
Big Clucker
 
Join Date: Oct 2018
Posts: 82
Reputation: 27
Default Re: Help me

I literally already gave you a functioning code snippet for exactly that.
cSharp is offline   Reply With Quote
Old 02/05/2019, 12:35 AM   #8
raydx
Huge Clucker
 
raydx's Avatar
 
Join Date: Feb 2017
Posts: 205
Reputation: 73
Default Re: Help me

strexplode with \n delimiter.

https://github.com/oscar-broman/strl...ter/strlib.inc

Code:
/*
 * Split a string by a given delimiter.
 * 
 * Parameters:
 *   output[][] - A multi-dimensional array that will be filled with substrings.
 *   input[] - The input string to split.
 *   delimiter[] - The delimiter to split by. Defaults to ",".
 *   limit - The max. no. substrings.
 *   trim - Whether to trim the substrings from whitespace. Defaults to true.
 *   ignorecase - Whether the search for "delimiter" should be case-insensitive.
 *   size1 - The size of the 1st dimension of output (otput[this][]). Defaults to sizeof(output).
 *   size2 - The size of the 2nd dimension of output (otput[][this]). Defaults to sizeof(output[]).
 *
 * Returns:
 *   The number of substrings that were copied into the array.
 */
forward strexplode(output[][], const input[], const delimiter[] = !",", limit = cellmax, bool:trim = true, bool:ignorecase = false, size1 = sizeof(output), size2 = sizeof(output[]));
Example:

Code:
new new_message[10], strloop_count;
strloop_count = strexplode(new_message, TutorialData[index][tutorialMessage], "\n");

for (new in = 0; in < strloop_count; in++)
{
    SendClientMessage(playerid, -1, new_message);
}
raydx is offline   Reply With Quote
Old 02/05/2019, 02:40 PM   #9
akib
Huge Clucker
 
akib's Avatar
 
Join Date: Jun 2016
Location: Bangladesh
Posts: 274
Reputation: 2
Default Re: Help me

Quote:
Originally Posted by raydx View Post
strexplode with \n delimiter.

https://github.com/oscar-broman/strl...ter/strlib.inc

Code:
/*
 * Split a string by a given delimiter.
 * 
 * Parameters:
 *   output[][] - A multi-dimensional array that will be filled with substrings.
 *   input[] - The input string to split.
 *   delimiter[] - The delimiter to split by. Defaults to ",".
 *   limit - The max. no. substrings.
 *   trim - Whether to trim the substrings from whitespace. Defaults to true.
 *   ignorecase - Whether the search for "delimiter" should be case-insensitive.
 *   size1 - The size of the 1st dimension of output (otput[this][]). Defaults to sizeof(output).
 *   size2 - The size of the 2nd dimension of output (otput[][this]). Defaults to sizeof(output[]).
 *
 * Returns:
 *   The number of substrings that were copied into the array.
 */
forward strexplode(output[][], const input[], const delimiter[] = !",", limit = cellmax, bool:trim = true, bool:ignorecase = false, size1 = sizeof(output), size2 = sizeof(output[]));
Example:

Code:
new new_message[10], strloop_count;
strloop_count = strexplode(new_message, TutorialData[index][tutorialMessage], "\n");

for (new in = 0; in < strloop_count; in++)
{
    SendClientMessage(playerid, -1, new_message);
}


error
Code:
error 048: array dimensions do not match
line
PHP Code:
strloop_count strexplode(new_messageTutorialData[index][tutorialMessage], "\n"); 
__________________
-

Akib Khan#4244
akib 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



All times are GMT. The time now is 04:04 AM.


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