DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • November 19, 2018, 04:29:24 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Changing the player's title  (Read 4471 times)
0 Members and 1 Guest are viewing this topic.
Odyssey
Guest
« on: June 13, 2004, 02:53:36 PM »

Looking at Lonny's Fortune Teller script gave me the idea, but I wasn't sure if it was possible to do.


In Lonny's script, he has differnt case numbers, which offer a random fortune.  I was thinking about making of them:


                           output("You will be cursed untill you defeat the dragon");
                           $session user title = Frogboy | Froggirl;

That second line is more or less psuedocode.   Then, what would happen, is that no matter what their current title is, it will now become Frogboy/girl $name, untill they defeat the dragon.  Once they do that, they will go to the next natural occuring title.

example:  If they are a Farmboy....then get switched to Frogboy.....defeat the dragon....become a Page
or, if a Page...become a Frog....kill dragon....then a Squire
and etc...
                           
Deminted?  Yes, of course!  Grin  But can it be done?
Logged
dvd871
Guest
« Reply #1 on: June 13, 2004, 03:18:24 PM »

Giving it a quick thought here is some idea:
Code:
if ($session[user][sex]==0){ //male
    $title = "frogboy";
} else {
    $title = "froggirl";
}

// insert whatever code you want here

//then set titles
$session[user][title] = $title;
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #2 on: June 13, 2004, 03:53:49 PM »

This should fit your need (code from dragon.php)

Code:
$newtitle=$alttitles[$session[user][dragonkills]][$session[user][sex]];
if ($newtitle==""){
    $newtitle = ($session[user][sex]?"Goddess of Frogs":"God of Frogs");
}
if ($session[user][title]!=""){
    $n = $session[user][name];
    $x = strpos($n,$session[user][title]);
    if ($x!==false){
        $regname=substr($n,$x+strlen($session[user][title]));
        $session['user']['name'] = substr($n,0,$x).$newtitle.$regname;
         $session['user']['title'] = $newtitle;
            }else{
         $regname = $session['user']['name'];
         $session['user']['name'] = $newtitle." ".$session['user']['name'];
         $session['user']['title'] = $newtitle;
    }
}else{
     $regname = $session['user']['name'];
     $session[user][name] = $newtitle." ".$session[user][name];
     $session[user][title] = $newtitle;
}
You  need to create an array in common.php similar to the existing one at the end of file:
Code:
$alttitles = array(
    0=>array("FrogBoy","FrogGirl"),
    1=>array("Frog", "Frog"),
    .
    .
    .
    30=>array("God of Frogs","Goddess of Frogs"),
);

That's it Wink

I haven't checked it yet, so it could be buggy, try at your own risk  Grin

Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Odyssey
Guest
« Reply #3 on: June 13, 2004, 04:38:39 PM »

Thank for the quick replies.  I'm working on it, based on your ideas.  I'm a little confused at this part:

This should fit your need (code from dragon.php)

Code:
$newtitle=$alttitles[$session[user][dragonkills]][$session[user][sex]];
if ($newtitle==""){
    $newtitle = ($session[user][sex]?"Goddess of Frogs":"God of Frogs");




Why am I pre-selecting a title, when there's an array to choose from?
Logged
Zanzaras
Captain of the Guard
***
Offline Offline

Posts: 220


*Snipe*


View Profile
« Reply #4 on: June 13, 2004, 05:36:13 PM »

I wrote a modification to change a player's title when their b'day rolls around (I think a few other people may have written one too). You can find it in my shared files. It may help you out some.   Smiley


http://dragonprime.cawsquad.net/users/Zanzaras/LotGD%20-%20Birthday%20mod%20instructions.rtf

Logged

"Intelligence is like a river, the deeper it is the less noise it makes."
anpera
Guest
« Reply #5 on: June 13, 2004, 07:42:31 PM »

If you want to give a player a persistent custom title that doesn't change after a dragon kill, just use the "ctitle" field. It was meant to be for custom titles chosen by the player in hunter's lodge, but if don't have such a function for customized titles you can use ctitle.

This is what you have to do in your code:
  • Set $session[user][ctitle] to the new title;
  • Change $session[user][name] to the new name;
In Code:
Code:
$newtitle = ($session[user][sex]?"Froggirl":"Frogboy");
$session[user][name] = ereg_replace($session[user][title],$newtitle,$session[user][name]);
$session[user][ctitle] = $newtitle;
That's it. The new title will stay in name even after a dragonkill, while the regular title changes without appearing in name. See dragon.php for the reason. Wink

To switch back to regular titles with normal changes after dragonkills just set $session[user][ctitle] to an empty string. With the next dragonkill the title will be a regular one. To accelerate it you can use the following script to replace the custom title in name with the correct and actual regular title:
Code:
$session[user][name] = ereg_replace($session[user][ctitle],$session[user][title],$session[user][name]);
$session[user][ctitle] = "";

Not tested, so be careful.
Maybe a str_replace(); would be even faster, but it should work this way too.
Logged
Kendaer
Guest
« Reply #6 on: June 13, 2004, 07:50:11 PM »

0.9.8 actually has correct and safe title changing code so you can just call a function with the new title (or ctitle or name) and it will be recomputed and the display name set correctly.  In the 0.9.7 code it was very easy for someone with the user editor to set a name such that the user's display name would get screwed in the next dk.

I urge you all to be very careful with name-changing code so that you don't put yourself into that boat Smiley
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #7 on: June 13, 2004, 10:20:28 PM »

Thank for the quick replies.  I'm working on it, based on your ideas.  I'm a little confused at this part:Why am I pre-selecting a title, when there's an array to choose from?

Those are alternative ($alttitle) titles, you need to write them in an array to substitute the existing ones. If you want to change from FarmBoy/FarmGirl to FrogBoy/FrogGirl, Page/Frog and so on you need to create a new array to choose from, that's the reason.

Rgds Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Odyssey
Guest
« Reply #8 on: June 16, 2004, 06:37:05 PM »

This is really my first attempt at making new code...

  I wasn't planning on different levels of Frogs, depending on what your DK is.  It was just going to be "Frogboy/girl" untill your title changed.  Like how Lonny coded the Saint in the Castle.

I'm going by the his code from the castle and other bits and pieces.  Could someone please let me know if I'm on the right path?

Code:
output("Your name will be ruined.");
         $name=$session[user][name];
         addnews("$name `7was `^cursed`7 by the Fortune Teller!");
         if ($session[user][sex]=0) {
         $newtitle="Frog Boy";
         }
         else {
         $newtitle="Frog Girl";
            $n = $session[user][name];
         $x = strpos($n,$session[user][title]);
         if ($x!==false){
            $regname=substr($n,$x+strlen($session[user][title]));
            $session['user']['name'] = substr($n,0,$x).$newtitle.$regname;
            $session['user']['title'] = $newtitle;
         }else{
            $regname = $session['user']['name'];
            $session['user']['name'] = $newtitle." ".$session['user']['name'];
            $session['user']['title'] = $newtitle;
         }
                           if ($session[user][hitpoints] > 0){
                          addnav("R?Return to the Forest","forest.php");
                              }
                              else {
                             addnav("Your dead $myname","shades.php");
                                 }
                           
                           break;


Thank you!!!
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
53 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search