Log in to ZYGOR
Log in with social media
OR
Log in with Zygor account

Announcement

Collapse
No announcement yet.

Programing Topic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Programing Topic

    I hope that both Zygor staff and those evil moderators on Zygor forum will accept this topic. Ok. They're not evil. They're cool

    Q: What can I do in this topic?
    A: Talk about any programing language, give other tips, share knowledge and more. =)

    That simpel and easy

    So I want to start this topic with a question I posted on another topic here on Off Topic forum:

    Originally posted by kjellboy View Post
    For the.... Horde? No,no,no.. For the Alliance

    So. Both of you are doing som programing eh? Then both of you can help me out with something x)

    First of all: I'm trying to learn PhP. But since i got a minor problem I can't get further into the lesson i'm at. I can't use my computer as an server. I need this to be able to see if my coding where correct. Need to se that I passed "Hello Word" thingy. x)

    Second of all: Any very good sites i can learn PhP and other programing languages on?

    Sorry my English

    And for those of us that got little to non experience with programing: How hard is LUA?

    And: Congrats with your book
    And btw. My OS is: Windows Vista Basic 32 bit(Laptop) Windows Vista Home Premium 32 bit(Desktop)

    Originally posted by deleon View Post
    kjellboy,

    You don't say what OS you're running or what server you need. However, if you're running a Windows OS, you could check if Microsoft Virtual PC will install (free download from Microsoft) and if it won't, you might try VMWare. Either way, create a virtual machine and load an appropriate OS (evaluation copy of Windows Server 2008 or Linux or ...)
    I got Windows as I mentioned here ;p

    Well. Share your knowledge about(example) C sharp, Java, C, PhP, HTML and the list goes on and on and on. Give other users tip on how to debug, how to program more effectively, solve a little problem and lots of other things. Have fun

    #2
    What I had always done, was used a free hosting site that allowed PHP scripts and tested around with it. http://x10hosting.com/freehosting.php is what I'd recommend.

    Your 'Hello World' script should look something like this -

    Code:
    <?php
    
    echo( 'Hello, world!' )
    
    ?>
    And there is the most basic thing you could ever create in PHP ;-).
    It may seem narcissistic to link this, but it's awesome nonetheless.

    Comment


      #3
      install WAMPServer from http://www.wampserver.com/en/, it's free and will install and cinfigure everything you need to make your pc into a fully functional apache http server , with PhP and mySQL installed and configured.

      For tutorials, the php site itself has tons of help, I can also thoroughly recommend w3schools.com for all web/internet based programming help/tutorials/reference. They cover html, php, mysql, javascript and a whole lot more.

      Comment


        #4
        Guys.. just install Web Server on a Stick and run that

        http://www.chsoftware.net/en/useware/mowesmixer/

        I develop all of my websites locally before uploading them over the live version. Always a pain when the users start spamming you with support emails while you are working on it :S

        I keep it all on my flash drive so I can work from any computer...


        Instructions for getting the MoWeS:

        Select that you do not have a package,
        packages I recommend (* indicated you've got to have it for what you are doing):

        * Apache2 (Version 2.2.11)
        * PHP4 (Version 4.4.9) (or 5; I prefer 4 as I use a couple of CMS' which are not yet up to speed)
        ImageMagick (Version 4.2.9)
        MySQL5 (Version 5.1.35)
        PHPMyAdmin (Version 3.1.2)

        Comment


          #5
          Just another comment on this..

          He's right; pretty much anything you can need can be found on php.net. Not only do they give examples for all functions, but users are ALWAYS posting their own, usually more complicated, solutions.

          My version of hello world >

          Code:
          <?php
          header("Content-type: text");
          print <<< END
           _______________________ 
          < Hello, bovine world!  >
           ----------------------- 
                  \   ^__^
                   \  (oo)\_______
                      (__)\       )\/\
                          ||----w |
                          ||     ||
          END;
          ?>
          o.0

          Comment


            #6
            Oh yeah? Well here is how I do mine!

            Code:
            #include <iostream>
            #include <string>
            
            int main( int argc, char* argv[] )
            {
                  std::cout << "Hello, everybody, if you're reading this.. then I'm already dead. Please.. tell my wife and kids that I love them, and I will be watchi..." << std::endl;
                  std::cout << "ERR - Message terminated. No more data." << std::endl;
            
                  return 0;
            }
            It may seem narcissistic to link this, but it's awesome nonetheless.

            Comment


              #7
              Oh, switching languages are we?

              Code:
              public class HelloWorld
              {
                   public static void main(String [] args)
                   {
                        System.out.println("Hello world!");
                   }
              }
              Code:
              DEFAULT_CHAT_FRAME:AddMessage("Hello world!")
              Gotta love the simplicity of LUA...

              Code:
              int main() 
               {
                      printf("hello, world");
                      return 0;
               }
              Code:
              10 PRINT "Hello World!"
              20 GOTO 10
              I swear it will eventually terminate o.o

              Yea.. I don't really know any other languages that well o.0
              I've been meaning to learn C# though so heres a try: (omg its Java for the XBox!)
              Code:
              using System;
              
              class HelloWorld
              {
                  public static int Main(String[] args)
                  {
                      Console.WriteLine("ZOMG its C# except I can barely tell it apart from Java!!!!");
                      return 0;
                  }
              }

              Comment


                #8
                To the guy who programmed the Zygor count down: Go to hell. I'm sitting here staring at it now even though I know I won't be able to use it even when it does come out :S

                Comment


                  #9
                  Oh, yeah? Well now what's up?

                  Code:
                  #include <iostream>
                  #include <string>
                  using namespace std;
                  
                  int main()
                  {
                  	int temp = 0;
                  	int nums[5];
                  
                  	for(int i = 0; i < 5; ++i)
                  	{
                  		cout << "[" << i << "]" << ": ";
                  		cin >> nums[i];
                  	}
                  
                  	cout << endl;
                  	cout << endl;
                  
                  	for(int i = 1; i < 5; ++i)
                  	{
                  		for(int k = 1; k < 10; ++k)
                  		{
                  			if(nums[i] < nums[k]) 
                                          {
                  				temp = nums[i];
                  				nums[i] = nums[k];
                  				nums[k] = temp;
                  			}
                  		}
                  	}
                  
                  	for(int i = 0; i < 5; ++i)
                  	{
                  		cout << "[" << i << "]" << ": " << nums[i] << endl;
                  	}
                  }
                  /flex.
                  It may seem narcissistic to link this, but it's awesome nonetheless.

                  Comment


                    #10
                    Lol. I wish I could put dynamic images into my avatar

                    Just finished coding this while bored because wow is down o.0
                    Code:
                    <?php
                    $name = stripslashes($_GET['name']);
                    $realm = stripslashes($_GET['realm']);
                    $allowed_combos = array(
                    				"Hadran" => "Quel'dorei"
                    				);
                    if(!$allowed_combos[$name] || $allowed_combos[$name] != $realm) {
                    	//have to do this so the PhP interpreter knows to tell the browser its getting an image, not an HTML file! otherwise you get a bunch of random seeming images!
                    	Header ("Content-type: image/png");
                    	$image = imagecreatefrompng('noperms.png');
                    	imagepng($image);
                    }
                    define("REALM", $realm);
                    define("NAME", $name);
                    
                    //first open curl handler. we will be using this to make a request of the wow armory server. why not just do a file_get_contents you ask?
                    //well, 'cause the armory requires a user agent and curl handles it very gracefully!
                    $curl_handler = curl_init();
                    curl_setopt ($curl_handler, CURLOPT_URL, "http://www.wowarmory.com/character-sheet.xml?r=".urlencode(REALM)."&n=".urlencode(NAME));
                    curl_setopt ($curl_handler, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt ($curl_handler, CURLOPT_CONNECTTIMEOUT, 40);
                    curl_setopt ($curl_handler, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4");
                    //this is where we do the actual reading of the XML files
                    $xmldata = curl_exec($curl_handler);
                    curl_close($curl_handler);
                    $parser = xml_parser_create();
                    xml_set_element_handler($parser,'onElementOpen','onElementClose');
                    //and now we trigger the parser :D
                    xml_parse($parser,$xmldata);
                    $character; //will contain the XML that I actually need once the parser completes
                    function onElementOpen($parser,$name,$attributes)
                    {
                    	global $character; //remember kiddies! variables in PhP are local by default!
                    	if($name == "CHARACTER") //this is the tag name that contains the relevant information
                    		$character = $attributes;
                    }
                    function onElementClose($parser,$name) {} //only need this as something to give the parser :D
                    //sample data because I always forget the index for stuff :D
                    /*Array ( [BATTLEGROUP] => Emberstorm [CHARURL] => r=Quel%27dorei&n=Hadran [CLASS] => Paladin [CLASSID] => 2 [CLASSURL] => c=Paladin [FACTION] => Alliance [FACTIONID] => 0 [GENDER] => Male [GENDERID] => 0 [GUILDNAME] => [LASTMODIFIED] => October 19, 2009 [LEVEL] => 14 [NAME] => Hadran [POINTS] => 70 [PREFIX] => [RACE] => Human [RACEID] => 1 [REALM] => Quel'dorei [SUFFIX] => [TITLEID] => 0 )
                    */
                    //I know this looks a tad convoluted, but wow only contains images for level 1-59, 60-69, 70-79, and 80 for your portraits. It doesnt change until you hit level 60! sheesh!
                    //anyway.. this works as such: if you are below level 60, you get the default image. if you arent, divide by 10, truncate, and then multiply by 10
                    //eg: level 79 / 10 = 7.9 (truncate) = 7 * 10 = 70
                    //the rest of the mumbo jumbo is to tack on the rest of the image file. wow structures it like gender-race-class.gif
                    $image = "http://www.wowarmory.com/_images/portraits/wow-".($character["LEVEL"] < 60 ? "wow-default" : (int)($character["LEVEL"]/10)*10)."/".$character['GENDERID']."-".$character['RACEID']."-".$character['CLASSID'].".gif";
                    
                    //have to do this so the PhP interpreter knows to tell the browser its getting an image, not an HTML file! otherwise you get a bunch of random seeming images!
                    Header ("Content-type: image/png");
                    
                    //now, I have a local copy of the background as a png which I am going to load. I modified the orignial one to have a nice little transparent box in the center
                    //why? you'll see later; makes it easier to layer the image
                    $background = imagecreatefrompng("background.png");
                    
                    //load the avatar... if you can't get it from the armory, that means it is down!
                    //so, if thathappens, we just go ahead and use the previous version that was loaded. 99.99% of the time this will give us the right image,
                    //but if you level from 59 to 60 while the armory is down you are out of luck until it comes back up :-D
                    $avatar = @imagecreatefromgif($image);
                    if($avatar) {
                    	imagepng($avatar, 'avatar.png');//to keep PhP happy (read: less work for us) we convert it into a png
                    	imagedestroy($avatar); //destroy the .gif we had as it is just a resource waste at this point :D
                    	$avatar = imagecreatefrompng('avatar.png'); //load the newly created image :)
                    }
                    else $avatar = imagecreatefrompng("avatar.png");
                    
                    //load both the background size and the avatar size
                    $background_size = getimagesize('background.png');  
                    $avatar_size     = getimagesize('avatar.png');
                    
                    //now, rather than doing what seems to be the smart thing and just merging the avatar onto the background,
                    //we are going to create new image, apply some transparency to it, and then paste first the avatar and then the background onto it
                    //why? so the circle is slightly on top of the avatar. otherwise the image would simply be on top of the circle (see the image to see what I'm talking about
                    $dest_image = imagecreatetruecolor($background_size[0], $background_size[1]);
                    $trans_color = imagecolorallocate($dest_image, 255, 255, 255);//here we allocate red as the color we want to make transparent. why? because I can!
                    imagecolortransparent($dest_image, $trans_color);//now we actually tell it to make that color transparent
                    imagefilledrectangle($dest_image, 0, 0, $background_size[0], $background_size[1], $trans_color);//now we draw over the black box with a red box of equal size
                    
                    //now, we first copy the avatar onto the image pallet at X=21, Y=16 (that puts it in the little window of the background
                    imagecopy($dest_image, $avatar, 21, 16, 0, 0, $avatar_size[0], $avatar_size[1]);
                    imagecopy($dest_image, $background, 0, 0, 0, 0, $background_size[0], $background_size[1]);
                    
                    //Now draw some text!
                    $fontcolor = imagecolorallocate($dest_image, 0xFF, 0xFF, 0xFF); //always remember to allocate a color you are going to be using :D
                    //This generates the bounding box positions (top left corner, top right corner, etc) which makes it easier for me to dyanmically position the level
                    //text into the circle
                    $bbox = imageftbbox(10, 0, './verdana.ttf', ($character['LEVEL'] ? $character['LEVEL'] : '??'));
                    //here we are drawing in the level text. Im using avatar size because the middle of the circle lines up with the middle of the avatar, so half the widht of the
                    //avatar plus its 21 pixel offset gives you the middle of the circle :D
                    imagefttext($dest_image, 10, 0, 21+($avatar_size[0]/2.0)-$bbox[2]/2.0, 97, $fontcolor, './verdana.ttf', ($character['LEVEL'] ? $character['LEVEL'] : '??'));
                    imagefttext($dest_image, 10, 0, 30, 127, $fontcolor, './verdana.ttf', NAME); //paste in the name since I don't care about achivement points. you can put that here if you really want to
                    if(!$character['NAME']) { //if there is no character name then we got jipped doing all that work! the armory is down! (tell the user why you are level ?? lol)
                    	$bbox = imageftbbox(10, 0, './verdana.ttf', 'Armory is down!');
                    	imagefttext($dest_image, 10, 0, $background_size[0]/2-$bbox[2]/2,15, $fontcolor, './verdana.ttf', "Armory is down! ");
                    }
                    //finally, output the image as a gif
                    imagegif($dest_image);
                    ?>
                    Except when I tell the forums to use that all it does is download the image and make it static

                    I even went to the trouble of adding a url rewrite so that it wouldn't complain that it was .php instead of .gif! :|

                    Last edited by popupman; October 20, 2009, 12:46 PM. Reason: [img] not [image] apparently

                    Comment


                      #11
                      Question about wow addon developing for addon developers.
                      How you 'reload' addon to see changes made in your addon. I don't like the idea of starting/closing wow each time i change something, especially if changes are related to visual things and i'm tweaking some positions, sizes, etc.

                      Comment


                        #12
                        Hello user2100,

                        I actually don't think you can. Unless it's '/console ReloadUi' to make changes to files, but I can't really remember. It's either:

                        A) You can modify files, but not add new ones, and use the /console ReloadUi command to see the changes.

                        B) You will have to restart for any changes made to the addon.

                        Just try A and if it doesn't work, then you'll have to resort to B. That's one of the most biggest problems I have with developing LUA scripts for different games, you have to constantly shut it down and bring it up to see the changes. Hope this helps.

                        Silverhawk11
                        It may seem narcissistic to link this, but it's awesome nonetheless.

                        Comment


                          #13
                          "Reloading your UI will purge the UI-Memory and load all AddOns which are activated but it will not load any AddOns that were placed in the Interface/AddOns folder since you started the World of Warcraft client. "

                          Comment


                            #14
                            Cool, so option A was correct.
                            It may seem narcissistic to link this, but it's awesome nonetheless.

                            Comment

                            Working...
                            X