Calling function from PHP - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Calling function from PHP (
/showthread.php?tid=609541)
Calling function from PHP -
bartje01 - 13.06.2016
Hello all,
Is it possible to call a samp function in game as soon as I fill in something like a PHP form in my webbrowser?
I am using MySQL.
Re: Calling function from PHP -
iGetty - 13.06.2016
Look into this:
https://sampforum.blast.hk/showthread.php?tid=104299
I think you're able to call commands from the API, using: $rcon->Call("LocalFunction");
Re: Calling function from PHP -
Vince - 13.06.2016
Socket plugin.
Re: Calling function from PHP -
bartje01 - 13.06.2016
Yup, I looked through that one already but I don't think that will let me call an actual function.
What I want to do is letting a bomb explode as soon as someone hits a button on my website. I have that working, but I have a timer running each second to check if a value in my database has changed. That means that I am running a select query every single second which I think is bad for the server performance.
This is the code:
Code:
SetTimer("bomb", 1000, true);
forward bomb(playerid);
public bomb(playerid)
{
new query2[128], query[128], active;
mysql_format(mysql, query, sizeof(query), "SELECT `active` FROM `explosions`");
mysql_query(mysql, query);
if(cache_num_rows())
{
active = cache_get_field_content_int(0, "active");
if(active == 1){
CreateExplosion(10, 10, 4, 12, 10.0);
mysql_format(mysql, query2, sizeof(query), "UPDATE `explosions` SET `active` = 0");
mysql_query(mysql, query2);
return 1;
}
}
return 1;
}
Is there perhaps a way to do this without having to do a query every second? Or isn't this too bad performance wise?