Race Event

  • Corleone Staff Forum Admin


    I've made a script which acts like a race. Once the player touches the object it will copy their appearance and warp them to a location on the map so that a prize can be rewarded to that player.

      //Reset the function
    function onUpdated(pl) {
        this.race_winner = null;
        this.race_timer_message = 0;
        this.scheduleevent(1, "updatemessage", pl);    
    function onPlayerTouchsMe(pl) {
        if (this.race_timer_message > 0) return;
            //Set the winner
        this.race_winner = pl.name;
        this.say("Winner: " + this.race_winner + "!");
            //Copy the players look to give it that special look :)
            //How long to keep the message on display so it cannot be touched
        this.race_timer_message = 60;
            //Potentially warp them some place within the map so the events team can easily find the winner 
        pl.setmap("flameboy","template_flameboy",this.x, this.y + 5);
        this.scheduleevent(1, "updatemessage", pl);
      //Every 3 seconds update the chat to say the winners name for the remainder of the 'this.race_timer_message'
    function onUpdateMessage(pl) {
        if (this.race_timer_message > 0) {
            this.say("Winner: " + this.race_winner + "!");
            this.race_timer_message -= 3;
            this.scheduleevent(3, "updatemessage", "");
        } else {
                  //Once the race_timer_message is less than or equal to 0, stop the timeout from running
            this.race_winner = null;
            this.race_timer_message = 0;

Log in to reply