SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 18/11/2013, 02:12 PM   #1
Emmet_
Guest
 
Posts: n/a
Default "PHP" sessions in PAWN

So over the past few days, I've been thinking of some unique ideas to effectively share data across other scripts, when I came across this idea: sessions

Basically, in PHP, you can do this:

PHP Code:
<?php

session_start
();

$_SESSION['texta'] = 'dog';
$_SESSION['textb'] = 'cat';
$_SESSION['textc'] = 'fox';

echo 
$_SESSION['texta']."<br/>";
echo 
$_SESSION['textb']."<br/>";
echo 
$_SESSION['textc']."<br/>";

session_destroy();
?>
And I'm developing a PAWN library that allows scripters to do this:

pawn Code:
main()
{
    session_start();

    session_set("texta", "dog");
    session_set("textb", "cat");
    session_set("textc", "fox");

    print(session_string("texta"));
    print(session_string("textb"));
    print(session_string("textc"));

    session_destroy();
}

And with this library, scripters can share this data across all scripts using the session_get functions.

But the real million dollar question: is it worth it? It uses a single SQLite database to temporarily save and fetch values until the session is destroyed, but I want to know if using a SQLite database is the best choice or if there are any other alternatives.

What do you think about this idea?
  Reply With Quote
Old 18/11/2013, 02:14 PM   #2
Sublime
High-roller
 
Sublime's Avatar
 
Join Date: Jul 2013
Location: 6ix god
Posts: 999
Reputation: 223
Default Re: "PHP" sessions in PAWN

And.. how/where will the result be printed (pawn) ?
__________________
Quote:
Originally Posted by Zorono View Post
Becuase its the best mod of GTA SA
and itsn't dead, Kalcor is having some proplems on his real life so he is busy now and release the new version now so shut your fucking mouse !!!!!!!!
Sublime is offline   Reply With Quote
Old 18/11/2013, 02:17 PM   #3
Emmet_
Guest
 
Posts: n/a
Default Re: "PHP" sessions in PAWN

Quote:
Originally Posted by Sublime View Post
And.. how/where will the result be printed (pawn) ?
server_log.txt lol

But the session_get function will fetch from a single SQLite database (db_get_field_assoc) that can be used between all scripts.
  Reply With Quote
Old 18/11/2013, 02:20 PM   #4
Isolated
Gangsta
 
Isolated's Avatar
 
Join Date: Mar 2013
Location: United Kingdom
Posts: 802
Reputation: 155
Default Re: "PHP" sessions in PAWN

I think you should use a different method as IMHO SQLite may not be necessary. Something like a include file would be suffice? Would you be limited in the amount of session items you can have?
Isolated is offline   Reply With Quote
Old 18/11/2013, 02:22 PM   #5
Sublime
High-roller
 
Sublime's Avatar
 
Join Date: Jul 2013
Location: 6ix god
Posts: 999
Reputation: 223
Default Re: "PHP" sessions in PAWN

It is well worth if people begin to use this in their script, tho I never saw anyone using this kind of stuff.
__________________
Quote:
Originally Posted by Zorono View Post
Becuase its the best mod of GTA SA
and itsn't dead, Kalcor is having some proplems on his real life so he is busy now and release the new version now so shut your fucking mouse !!!!!!!!
Sublime is offline   Reply With Quote
Old 18/11/2013, 02:30 PM   #6
Emmet_
Guest
 
Posts: n/a
Default Re: "PHP" sessions in PAWN

Quote:
Originally Posted by Isolated View Post
I think you should use a different method as IMHO SQLite may not be necessary. Something like a include file would be suffice? Would you be limited in the amount of session items you can have?
For now, there can only be one session at a time, but I was thinking of letting the scripter have as many sessions as they would like (indefinite) - all would save inside one database file (sessions.db).

Quote:
Originally Posted by Sublime View Post
It is well worth if people begin to use this in their script, tho I never saw anyone using this kind of stuff.
Probably. A lot of people use the GVar plugin for sharing data across filterscripts for example, but this library I am planning up will be way more advanced than GVar, with the ability to save arrays, hex and boolean values, and also save data into an .INI file.
  Reply With Quote
Old 18/11/2013, 02:55 PM   #7
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,465
Reputation: 382
Default Re: "PHP" sessions in PAWN

I don't get it, is it like GVars or what?

Edit: Just read your latest post, so it is. I don't know why would you create something which is already possible.
Edit2: Why don't you just use GVar and make an include which uses GVars to make that INI saving stuff possible.
Finn is offline   Reply With Quote
Old 18/11/2013, 04:24 PM   #8
Emmet_
Guest
 
Posts: n/a
Default Re: "PHP" sessions in PAWN

Quote:
Originally Posted by Finn View Post
I don't get it, is it like GVars or what?

Edit: Just read your latest post, so it is. I don't know why would you create something which is already possible.
Edit2: Why don't you just use GVar and make an include which uses GVars to make that INI saving stuff possible.
Well, it is a mixture of GVars and sessions from PHP, except that I've planned to make indefinite session ID's, a sorting feature, and an expiry time for values.

Edit:

Quote:
Originally Posted by ****** View Post
PAWN has this ability natively in "properties", the GVar plugin already replicates something that exists, why re-replicate it? If you want something better than what even the GVar plugin offers, why not just fork and update the GVar plugin?

I'll also point out that there is y_master too, in which this can be replicated in seconds.

Edit: In fact, generally PHP sessions are per-user data, so you have PVars for that.
Good point, but I don't really use properties since there are better and more efficient ways to share data across scripts (I remember you said something about properties having the same loading and saving style as PVars). It's also hard to keep track of the data stored in properties.

I have to give y_master a try also, currently checking out this thread. I also had an idea in mind for my gamemode regarding NPC's, and y_master can really be useful in this case.

This thread can be closed. Thanks everyone!
  Reply With Quote
Old 18/11/2013, 11:53 PM   #9
SuperViper
High-roller
 
SuperViper's Avatar
 
Join Date: Sep 2011
Posts: 1,178
Reputation: 315
Default Re: "PHP" sessions in PAWN

Quote:
Originally Posted by ****** View Post
Something like this ENTIRELY UNTESTED code:

pawn Code:
some untested code here


quote by ******
__________________
Release NameUse
FairPlayKeep the cheaters out of your server
Object Model ArrayArray of every single object model in the game
RCON PanelControl any server as you like with RCON controls
SlopeClimb up a steep hill against other players with cars falling down

I do not play on any SAMP server. Anyone with the name Ricky Phelps in-game is an imposter.
SuperViper is offline   Reply With Quote
Old 19/11/2013, 01:32 AM   #10
Bakr
Gangsta
 
Join Date: Apr 2011
Posts: 975
Reputation: 198
Default Re: "PHP" sessions in PAWN

Quote:
Originally Posted by SuperViper View Post


quote by ******
"If you are replying to a problem"

He was giving a brief outline of how something may be accomplished, not responding to a problem of the OP. I suspect you will be going around to every post in this forum now to point out this exploited rule, or did you only do it for him so you could gain some attention for yourself?

Quote:
Originally Posted by Emmet_ View Post
It's also hard to keep track of the data stored in properties.
How so if I may ask? You can write some simple macros to basically replicate the same effect of what you are trying to do with this library with properties.
__________________

Looking for some people to help me with script testing. If you would be interested, send me a PM.

Quote:
Originally Posted by RiChArD_A
Bakr, what have done to you . You don't know me to be saying that I'm lazy. Your fucked ass mom is the only idiot here, ass hole.
Bakr is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: undefine symbol "j" and expected token ";" but found "]" JEkvall95 Scripting Help 9 27/07/2013 11:09 AM
[Off] Só existe o "pawn" para compilar "criar GM\FS" lucaspilar Português/Portuguese 11 11/06/2013 04:41 AM
5 Dialog errors - Input line too long, undefined symbol "t","is" and "only" Deal-or-die Scripting Help 6 01/05/2012 01:08 PM
"Bots", "AI", "NPCs"... Computer-controlled pedestrians and traffic! ssflsnoob General 2 23/11/2008 07:06 PM


All times are GMT. The time now is 06:25 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.