View Full Version : http and get [SOLVED]
nl2dav
10th November 2009, 01:43
http("http://www.demourl.nl/lfs_plugin.php?u=". GetCurrentPlayerVar("UserName") );
This doesn't seem to work :shrug:
Is it possible to use a variable in an url?
nl2dav
10th November 2009, 02:03
In fact...
"Normal" http requests doesn't seem to work either. Is that true? :really:
http("http://www.demourl.nl/lfs_plugin.php" );
I doesn't see any request trying to be made in my HTTP server log.
Are http requests limited to http://www.frh-team.net ... Hope not :eye-poppi
Fire_optikz001
10th November 2009, 02:08
In fact...
"Normal" http requests doesn't seem to work either. Is that true? :really:
http("http://www.demourl.nl/lfs_plugin.php" );I doesn't see any request trying to be made in my HTTP server log.
Are http requests limited to http://www.frh-team.net ... Hope not :eye-poppi
well i hope u arnt trying to connect to demourl.nl as that isnt even a real url :P
nl2dav
10th November 2009, 02:18
No :razz:
I used search and discovered that there is someone with a similar idea like I have.
http://www.lfsforum.net/showthread.php?p=1265539#post1265539
demourl is just there for people like Fire_optikz001 who are too curious :D
But its basically a true/false generator based on laps someone made. To keep crashers and fake accounts out of our races.
//edit: LOL, I just realized thats your thread :D :D
nl2dav
10th November 2009, 02:56
Sigh...
I'm used to use // when I comment on my own code
If you do that all upcoming code turns invalid. Its working now :thumbsup: :smileypul
* Also I would like to add that it looks like you can only use the http instruction once during an event.
Fire_optikz001
10th November 2009, 03:32
thats not nice :P why not use a login sys? which culd be hard or very easy :P
nl2dav
10th November 2009, 03:50
Why do I want another login systeem?
It destructs the open character of the game. The only people I don't want are the not so serious people.
The lap threshold is working now, maybe I put in a PB threshold or a win/second/third threshold as well...
Got to find out how this develops.
Krayy
10th November 2009, 03:58
I've sent a patch to Gai-Luron which should make http handling a lot more useful. Hopefully he will include it in the next update.
Gai-Luron
10th November 2009, 09:41
Hello,
i think there is a misunderstanding on how work http request. When you send a request to a web server LFSLapper attemps to receive a GLScript code and execute it.
Example
if i use you web call: you send a request to know if player is allowed, http("http://www.demourl.nl/lfs_plugin.php?u=". GetCurrentPlayerVar("UserName") );
and GetCurrentPlayerVar("UserName") -> "gai-luron"
web response can contain this glScript lines:
$allowed = 1;
$userName = "gai-luron";
doMyCode( $userName,$allowed );
OR
doMyCode( "gai-luron",1 );
LFSLapper interpret this GLScript code and in this code you can see you have a call to subroutine. This subroutine can be declared in lpr file.
In you lpr file tou have:
SUB doMyCode( $userName,$allowed )
... Do what you want if lpr file
IF( $allowed == 0 ) THEN
cmdlfs( "/kick " . $userName );
ELSE
privMsg("Allowed");
ENDIF
ENDSUB
And other way is to put all code in the returned webcommand
Request = http("http://www.demourl.nl/lfs_plugin.php?u=". GetCurrentPlayerVar("UserName") );
Returning web commands if allowed:
privMsg("Allowed");
Returning web commands if not allowed:
cmdlfs( "/kick gai-luron");
It's a very flexible system more than returning value inline, i hope i'am clear.
Krayy i see your code but it's not usefull when you know how webreturn work. Thank's anyway
Gai-Luron
PS: You can put any GLScript command in returned web, like top(), topuser(), etc...
nl2dav
10th November 2009, 14:29
Yes, excellent reply... Thank you.
Its already working and doing great :nod:
# check minimum amount of laps
$laps_username = GetCurrentPlayerVar("UserName");
http("http://demourl.nl/lfs_plugin.php?u=". $laps_username );
<?
$username = $_GET['u'];
$req = '';
$check_XRG = '';
$check_XFG = '';
$fp = fopen ("http://www.lfsworld.net/pubstat/get_stat2.php?version=1.4&idk=use_your_own_here_please&action=pb&racer=".$username."&s=1", "r");
while (!feof($fp))
{
$req .= fread($fp, 500);
}
fclose($fp);
$lfs_php_array = json_decode($req);
if (sizeof($lfs_php_array) == 0) {
echo "error";
die();
}
for ($i = 1; $i <= sizeof($lfs_php_array); $i++) {
$n = $i - 1;
if ($lfs_php_array[$n]->track == "000" && $lfs_php_array[$n]->car == "XRG") {
if ($lfs_php_array[$n]->lapcount > 40) {
$check_XRG = 1;
}
else {
$check_XRG = 0;
}
}
if ($lfs_php_array[$n]->track == "000" && $lfs_php_array[$n]->car == "XFG") {
if ($lfs_php_array[$n]->lapcount > 40) {
$check_XFG = 1;
}
else {
$check_XFG = 0;
}
}
}
if ($check_XFG == 1 OR $check_XRG == 1)
{
// echo 'globalMsg("true");';
}
else
{
echo 'privMsg("^3Woops you are a newbie! Please come back in 3 days, bye!");';
echo 'GlobalMsg("'.$username.' is unexperienced (<40 laps /car) and gets a 3 day ban");';
echo 'cmdLFS("/ban '.$username.' 3" );';
// echo 'GlobalMsg("'.$username.' - XFG: '.$check_XFG.' XRG: '.$check_XRG.'");';
}
?>
The only flaw is that it generates an error if it requests stats within 5 seconds, could fix that by using multiple stat idk's but I think its OK for now.
Gai-Luron
10th November 2009, 15:53
You can insert a tarpit in your php Script and retry 5 second later.
Receive WebCmd in LFSLapper is asynchronus and don't freeze working of LFSLapper in waiting to receive web response.
Soon, LFSLapper retreive by ownself this stats values.
Gai-Luron
Krayy
10th November 2009, 19:31
Hello,
i think there is a misunderstanding on how work http request. When you send a request to a web server LFSLapper attemps to receive a GLScript code and execute it.
Example
if i use you web call: you send a request to know if player is allowed, http("http://www.demourl.nl/lfs_plugin.php?u=". GetCurrentPlayerVar("UserName") );
and GetCurrentPlayerVar("UserName") -> "gai-luron"
...
Ahhhh...I wondered why it was creating the WebReturnFunction function dynamically. Very clever and flexible to boot.
Let me know if my "suggestions" start get annoying :razz:
nl2dav
10th November 2009, 21:37
Good to know its asynchronous but I hate delays if they are not necessary so I extended the routine with an extra IDK ;)
Gai-Luron
10th November 2009, 22:53
Ahhhh...I wondered ...
Let me know if my "suggestions" start get annoying :razz:
No no problem :) you can continue, it's a better way to learn on how work Lapper. If i don't want suggestions, i don't release source and i make a "closed" app. you can't know everything on Lapper, me too i forgot many things on LFSLapper and some user know my app better than me :D
Gai-Luron
Fire_optikz001
11th November 2009, 14:07
wow that's cruel a 3 day ban for just because they haven't drove 40 laps
Krayy
11th November 2009, 18:55
wow that's cruel a 3 day ban for just because they haven't drove 40 laps
Hell it takes me 2 days to do 20 laps in an RAC, so why not?
nl2dav
11th November 2009, 20:36
Yeah maybe 1 day is okay too... But most newbies are not doing 40 laps in one day.
Somehow its not checking user accounts with a space, got to find out why.
The script above is old anyway, contains more bugs.
Fire_optikz001
11th November 2009, 21:57
Hell it takes me 2 days to do 20 laps in an RAC, so why not?
XD noob:shy: i can do 20 lap races in about an hour ... in xfg
hotmail
12th November 2009, 10:33
XD noob:shy: i can do 20 lap races in about an hour ... in xfg
/off topic.
Please upload it on the follow combo : AS7R and XFG
You Noob, how can you say that. he got a good point...
Fire_optikz001
13th November 2009, 01:47
/off topic.
Please upload it on the follow combo : AS7R and XFG
You Noob, how can you say that. he got a good point...
u heard of sarcasm?
Krayy
13th November 2009, 01:50
u heard of sarcasm?
Apparently not in Holland...Ishint dat veeerdt? I love Goooooooolllllld!!!!
P.S You want a schmoke and a pancake? How bout a shigar and a waffle?
nl2dav
16th November 2009, 18:40
Ey! Don't generalize a complete nation just because of one posting :really: :smileypul
It's a demo problem anyway. I suppose you don't need these kind of measurements when running a S1 or S2 server. The people there are already lost on those servers :D
Krayy
16th November 2009, 21:02
Ey! Don't generalize a complete nation just because of one posting :really: :smileypul
Sorry about that, but Goldmember WAS a funny movie :D
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.