Posts: 228
Threads: 28
Joined: Jan 2010
Reputation:
0
Hello guys.
I have some ideas how to do some stuff but it is better to ask for your opinion about the best methods for doing it.
I want to do something on the web page (eg. press a button to collect a reward) and then the php server will inform the samp server about that change (if the player is online - update his money, if not the update the mysql database).
I found 2 possible solutions on this forum, the sockets plugin by BlueG and the php libraries by Y_Less.
So i wanted to ask you guys what is the better solution for this kind of stuff?
The most important part is if that player is online, how to update his information via php accessing samp. Thank you
Posts: 228
Threads: 28
Joined: Jan 2010
Reputation:
0
Read the post, I want to be able to update the user stats if they are changed by the web server (eg. an admin bans a player via admin web panel, or gives a level to a player etc.)
Posts: 228
Threads: 28
Joined: Jan 2010
Reputation:
0
@Kwashiorkor thanks for that solution too, but I don't think that is too secure?
@zgintasz nice idea for the tasks way, didn't think about that al all! It would be very elegant to do it like that, without the need of extra plugins or libraries, but would it be efficient to access the table whole the time with a timer ?
ps. using mysql plugin r6 (blueg)
Posts: 367
Threads: 55
Joined: Oct 2011
Reputation:
0
I'm not sure about efficiency, but if mysql plugin supports threaded scripts, you may do that in separate thread. Also, using this method("tasks") would be much easier and simplier than sockets or anything else.
Posts: 1,336
Threads: 30
Joined: Aug 2010
Reputation:
0
it will be possible if u are able to send data to samp_srvr.exe which afaik is possible.
u can use OnRconCommand and something php thing to send message to console.
Posts: 15,941
Threads: 0
Joined: Jun 2008
I'm really not sure what people's obsession with using MySQL for everything is! It is a storage system, not a communication system, and using it as such is REALLY not the best way. Given the option, I'd say go with the sockets plugin - that IS a communication system and will be VASTLY more efficient than using an enterprise class highly resilient database system (which in this case will work against you through the vast overheads involved in safely writing all the data to disk).
Posts: 15,941
Threads: 0
Joined: Jun 2008
Why, what's the problem with more plugins? They don't have any serious overhead associated with them (except the MySQL one, which requires libmysql).
Posts: 4,878
Threads: 85
Joined: Jun 2007
Reputation:
0
Just repeating what already was said, id go either with sockets, or with the rcon api. These are the only two effective ways to do it in realtime.
Querying is an easy and secure way when you got the samp- and webserver on the same machine. No external communication then, and your data is as safe as the rest of your stuff, so there wouldnt be an extra risk.
Sockets would need some additional knowledge, but shouldnt be a problem for anyone with pawn and php skills.
Posts: 367
Threads: 55
Joined: Oct 2011
Reputation:
0
If he use sockets, he will need more knowledge, I'm not sure if he wants to learn about that. Maybe he just want to make this thing fast and easily.
Anyway, using php, sockets using is easier than using c++, so I don't know which way should he choose...
Posts: 966
Threads: 5
Joined: Jul 2011
Reputation:
0
I think that the sockets plugin is the best way to approach webserver to gameserver and vice versa communications. For simple one-way comms, you could also take advantage of the HTTP() function.
When you know how to do some PHP, you can also manage setting up and caching data in the memory using APC for example.
Posts: 15,941
Threads: 0
Joined: Jun 2008
Actually, you can use HTTP for two-way comms because the web server returns data. That's how y_php works.
Posts: 228
Threads: 28
Joined: Jan 2010
Reputation:
0
Yes but the web server responds only when a HTTP is sent from the samp server to the web server, but there is no way to triger a callback directly when data is sent from the webserver first, and that is exactly what I want.