Results 1 to 7 of 7

Thread: Help With Event Script using Multiple Words

  1. #1
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029

    Help With Event Script using Multiple Words

    Hiii, I have coded an event script for staff to use. I'm running into this issue however. Using multiple words in the event name leads to having commas after each word. Is there another way to do this without adding multiple word events into an array?

    PHP Code:

        
    // Check when the chat ends for events with multiple words
        
    for (temp.19i++) {
          if (
    temp.tokens[i] == NULL) {
            
    temp.i;
            break;
          }
          if (
    == 8) {
            
    player.chat "Error! Your event must be less than 8 characters!";
            return;
          }
        }
        
        
    // Check to see if the time is a valid time
        
    for (temp.061i++) {
          if (
    temp.tokens[temp.1] == i) {
            break;
          }
          
    // If i reaches 60, they did not enter a valid time
          
    if (== 60) {
            
    player.chat "Error! Syntax: /events 'The event' 'Time (less than 60 seconds)'";
            return;
          }
        }
        
        
    // Extra verification
        
    if (temp.tokens[1] == NULL || temp.tokens[2] == NULL) {
          
    player.chat "Error! Syntax: /events 'The event' 'Time (less than 60 seconds)'";
          return;
        }
        
        
    // Add the event to an array for events with multiple words
        
    temp.eventT = {};
        for (
    temp.1temp.1i++) {
          
    temp.eventT.add(temp.tokens[i]);
        }
        
    onEvent(temp.eventTtemp.tokens[temp.1]); 
    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  2. #2
    I'm not sure what the command your using contains (other than the event name), but instead of using tokens, you can just use the substring function. (/scripthelp substring in RC for usage).
    If you have other things you use in the command (like: /host #ofEC timeUntilEventWarp&Start eventName), then you can use a combination of tokens and the substring function. You could collect the rest of the event name as follows (assuming its the last parameter):
    temp.chat = player.chat; // the /host command
    temp.eventName = temp.chat.substring(temp.chat.pos(tokens[index # of the 1st word in event name]));

    or something roughly of that nature. By ignoring the optional parameter of [length], it goes until the end of the string.

  3. #3
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Quote Originally Posted by DanTheMan View Post
    I'm not sure what the command your using contains (other than the event name), but instead of using tokens, you can just use the substring function. (/scripthelp substring in RC for usage).
    If you have other things you use in the command (like: /host #ofEC timeUntilEventWarp&Start eventName), then you can use a combination of tokens and the substring function. You could collect the rest of the event name as follows (assuming its the last parameter):
    temp.chat = player.chat; // the /host command
    temp.eventName = temp.chat.substring(temp.chat.pos(tokens[index # of the 1st word in event name]));

    or something roughly of that nature. By ignoring the optional parameter of [length], it goes until the end of the string.
    I didn't explain it enough sorry. The temp.tokens comes from player.chat.tokenize(); The concept of my script was when I say "/event Chance 60", a GUI would appear on everyones client for 60 seconds. Later, I realized I ran into the issue of having multiple words in the event name. I added stuff to my code (see original post) to make it work as such. However, the way I'm doing it now seperates each word of the event with commas because I stored it in an array

    If I were to do "/event Water Race 60", I would get this result:

    The event Water, Race is being hosted! Countdown: (the countdown here)

    How can I code it differently so that the comma doesn't appear?

    I tried doing this but it didn't work:

    PHP Code:
    temp.eventT temp.tokens.substring(temp.tokens[1], temp.tokens[temp.2]); 
    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  4. #4
    Well, you aren't using substring correctly xD. If you have only two parameters as inputs (event name and time), then keeping it in the format you have (tokens), you can do something like this:
    PHP Code:
    // other checks here
    temp.tokens player.chat.tokenize(" ");
    temp.eventTime temp.tokens[temp.tokens.size() - 1]; // Last parameter/token is the time
    temp.eventName temp.tokens[1]; // First (and possibly only) word of the event name
    for (temp.2temp.< (temp.tokens.size() - 1); temp.++) { // Start at index 2, (index 0 is the /event command), loop until last token;
     
    temp.eventName @= " " temp.tokens[temp.i]; // Concatenate tokens to form full event name (if required)

    Although I haven't tested it, it is something like that.

    EDIT: I have tested it, works like a charm.
    Last edited by DanTheMan; 01-09-2016 at 11:24 PM.

  5. #5
    Big Cheese Captain
    Join Date
    Jun 2013
    Posts
    1,029
    Quote Originally Posted by DanTheMan View Post
    PHP Code:
    temp.eventName @= " " temp.tokens[temp.i]; 
    This was what I was looking for! Thank you what does "@=" do excacly and why do you have to have those quotes after the equals sign?
    iEra Developer / SFX Admin

    Need help? Contact me:
    Email: [email protected]

  6. #6
    Well, '@' concatenates (joins) the strings together as a whole. When its using in that form, its essentially saying: temp.eventName = temp.eventName @ (" " @ temp.tokens[temp.i]); And those quotes are introducing a SPACE, otherwise it would be like: WaterRace, SuperSparTourney, etc instead of Water Race or Super Spar Tourney.

  7. #7
    Street Boss Mr LebJoe S's Avatar
    Join Date
    Aug 2014
    Location
    liechtestein
    Posts
    781
    Quote Originally Posted by DanTheMan View Post
    Well, '@' concatenates (joins) the strings together as a whole. When its using in that form, its essentially saying: temp.eventName = temp.eventName @ (" " @ temp.tokens[temp.i]); And those quotes are introducing a SPACE, otherwise it would be like: WaterRace, SuperSparTourney, etc instead of Water Race or Super Spar Tourney.
    Oo! Okay, now I understand the script...
    ineffable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •