troublesum's Recent Forum Activity

  • mdvgames - unfortunately i don't... The example I provided in this thread needs work to enable the ability for peers to call functions on specific peers instead of just being able to call them on all peers all the time. (and the process is complicated enough as it is) it was just a proof of concept i created but lead me to work on my plugin instead. You will need to hack it to correct for any imbalances. (Ie if peerid already exists dont re-respawn it.)

    I would release my plugin that simplifies the whole thing but i'm not supporting it as it hooks into official (multiplayer & function) plugins maintained by Ashley and as he makes changes to them could break mine and would leave your project broken unless i correct for any changes he might make which i don't want to be responsible for. .. If you message me ill provide you a link to download it for personal use but to use at your own risk that someday it could be broken and I might not be around to fix it.

  • ah.. i see what your saying. I haven't looked at this in a while and didn't see that bug. Yah the problem is when the peer asks the host to send him all other peers, the host calls the "spawn_Player" function for everyone and not just the peer that requested it. I forgot about that problem and was why I stopped using this .. Trying to coordinate functions to "specific" peers was too complicated in the event sheet so i created a personal plugin that wraps the multiplayer and function plugins together so it does it all for me in a single call. On the example capx however you can just add a check to the "spawn_Player" function that if an object with that peerid already exists to ignore its creation.

  • azrail13 - have you tried just displaying the the AJAX.lastdata in a text object to see what your getting back. After looking at your login.php I can see a few errors that might come up. You say this worked when it was in testing but I can't see how. you might be getting a SQL error and not even know it becuase you are storing the result in an (int) variable so the string is just getting converted to a 0 (int zero)

    Maybe SQL has gotten better at adapting to syntax usage but his looks like it shouldn't work?

    $qz = "SELECT id FROM members where username='" . $username . "' and password='" . $password . "'";
    $qz = str_replace("\'", "", $qz);
    $result = mysqli_query($con, $qz);
    [/code:1joqfaoj]
    
    You are stripping single quotes from the query string before executing it but that means you are comparing columns (username & password) to non string values which SQL will interpret as other columns and throw an error because they don't exist
    
    Example 
    "WHERE username=player1 &password=test" will throw an error becuase SQL will think the values "player1" and "test" are columns  since they are not in single quotes
    
    It should be "WHERE username='player1' &password='test'" (The single quotes allow SQL to know you compairing the column value to a string value and not another column or equation
    
    And while this might work it is extremely unstable way of getting the data. On the off chance more than row is returned this will break and what if the username and password don't find a match? 
    [code:1joqfaoj]
    while ($row = mysqli_fetch_array($result)) {
        echo $row['id'];
    }
    [/code:1joqfaoj]
    
    Try using this
    [code:1joqfaoj]
    
    //make sure param is there and catch it if not so PHP doesn't throw a Notice error
    $username = isset($_GET['fname']) ? $_GET['fname'] : '';
    $password = isset($_GET['fpass']) ? $_GET['fpass'] : '';
    
    //Validate you received the params you expected
    if($username=='' || $password==''){
        echo 'Invalid login';
        exit; //make sure no other code is executed beyond this error;
    }
    
    //protect from SQL injection
    $username =  mysqli_real_escape_string($con,$username); 
    $password =  mysqli_real_escape_string($con,$password);
    
    //You need the single quotes around the values or SQL will break
    $qz = "SELECT id FROM members where username='" . $username . "' and password='" . $password . "'";
    $result = mysqli_query($con, $qz);
    
    //There should only be 1 row returned. No need for a while statement
    $row = mysqli_fetch_array($result);
    
    //The $row may be null if it was invalid username and password combo
    if(!$row){
        echo 'Invalid login';
        exit; //make sure no other code is executed beyond this error;
    }
    echo $row['id']
    [/code:1joqfaoj]
    
    Lastly keep in mind that $row['id'] will be returned as a string (all echo statements doesnt matter what they are are returned in string type as literal text) 
    
    so first in C2 you need to compare against the possible error and catch it
    Condition (AJAX.LastData=='')  - Ajax was empty and something went wrong. stop code
    Condition (AJAX.LastData=='Invalid login') - Ajax returned a notice of invalid login and you need notify the user so they can try again 
    
    Then if that passes you need to store it in userid but convert the (string) you received from php to (int) so it is casted correctly to the userid variable
    Action userid = int(AJAX.LastData)
  • mdvgames - I don't think i understand your question? Are you having a problem?

    The idea is that when a peer successfully connects he calls a function "Spawn_Player" locally on his device and pass it his peer id and start location to create him self on his screen. He then calls a function "sync_SpawnPlayer" that will call that same function all other peers devices with the same information so now his peer object is created on everyone else's screen too. The sync message is really only sent to the host and then the host will broad cast it to the other peers so they call function he wanted with the parameters he passed.

  • Radulepy - Its been a while since I've checked but I'm pretty sure current exporters don't support WebRTC yet (someone please correct me if you know differently) so you can't even make multi-player games as stand alone apps yet.

    So assuming its multi-player game using Official C2 Multiplayer Plugin (Uses WebRTC) the game files need to be launched in a real browser (That supports WebRTC as not all of them currently do) from a real website that people will go to, to play the game. That domain has to be hosted somewhere. If I go to Radulepy.com to play the game, that domain name has to translate to an IP address somewhere on the internet that is serving the game files that will launch the game on my computer. How will people find your game with out the game files being served to them from a server either hosted by you or externally that you pay for?

  • Paincho hmm.. Only other things i can think of is if this server has a website running on it and Apache or IIS is running and listening to those ports it will prevent node from starting the listener. If you have no other web services running the I would suggest restarting the computer if you haven't tried that to clear any old node listeners that may not have closed properly due to an improper start (I had to do this a few times). Other than that if by some chance the host specifically requires a domain name and wont work from IP (its a long shot as I don't fully understand web-sockets but know enough to be dangerous) you may need to purchase a domain name and point it to your public ip

  • Does this server have a direct connection to the internet from that IP or is it behind a router? You may have to forward port 443 and 80 from the router to the local IP (192.168.x.x) of the server so the path can be completed.

  • While creating a webworker that can execute dynamically generated code (ex. action script inside a function) is possible it would be complex to achieve though as you would need an algorithm to prep code and stringify it to be executed in a eval() statement in the worker, on top that and the elephant that really prevents this from being usable is that web workers have no access to DOM objects including the canvas for drawing purposes. You can only run large equations the work with specific variables (path finding) or data management actions (sorting or re-configuring array data) that have no DOM requirements in it.

    If you wanted to try and create your own plugin this will get you started.

    Method for taking all code inside a function and converting it to a string to be passed to the eval statement

    function stringifyFunction(callback) {
        //used to return stringified code from a function to make eval() usage easier
        var string = callback.toString();
        var startPos = strpos('{', string) + 1;
        string = string.slice(startPos, string.lastIndexOf('}'));
        return string;
    }
    [/code:t6z1jcpd]
    
    Your action script
    [code:t6z1jcpd]
    var worker = new Worker("workerFilePathGoesHere");
    
    var workFunction = stringifyFunction(function(){
        
        //this puts the cart before the horse as you will below this send the data variable
        //IE  data.test = 42;
    
        var response;
     
        //dynamic code goes here acting on the data you passed to it and sets something in response variable
    
         response = data.test + 1;
    
        //send response back when finished
        postMessage(response);
    
    })
    
    var data = {
        test : 42
    }
    
    //Send
    worker.postMessage({
        data : data,
        work : workFunction
    })
    
    //Receive
    worker.onmessage = function (e) {
    	   var response = e.data;
               //response = 43
               // the response from the work file will be here.
               // after ward you can trigger anything else on the even sheet and pass or store this response as needed
    	    worker.terminate();
    	}
    [/code:t6z1jcpd]
    
    worker file that can work on dynamically generated stringified code
    [code:t6z1jcpd]
    self.addEventListener('message', function(e) {
        var data = e.data.data
        eval(e.data.work);
        self.close();
    })
    [/code:t6z1jcpd]
    
    I can't take you any farther but good luck
  • its possible but it will probably be more work than its worth.. You can send an AJAX request to your PHP server and then call a PHP function to read a webpage to string

    $content = readfile("https://google.com/")

    with google you can pass it search parameters in the URI string Example.

    $content = readfile("https://www.google.com/#q=scirra")

    From there you can parse the html code received and do what ever you want with it but you're in effect attempting to create a webcrawler and parsing HTML is a daunting task. I wish you luck in your journey.

  • Moved files to drop box and updated the links... they can be downloaded again.

  • Yah.. the forum doesnt support files any more.. i need to upload it to drop box and create a link.. ill gget the links up tomorrow

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • On a final note, I do remember that ashley told rexrainbow... or someone on the forums that it was a bad idea to call the aces of another behavior from within a behavior.

    Ruskul - It is bad ... because it creates a dependency on other plugins that the user might not have and if those plugins get updated by Ashley the new changes might break your code or worse yours breaks the functionality of the existing plugin. That's why I wont release this plugin. I don't want to pollute the C2 ecosystem with a plugin that may become defective and not work in the future and some poor dev cant open his project in the future because of it.

troublesum's avatar

troublesum

Member since 4 Dec, 2013

Twitter
troublesum has 2 followers

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies