Loading job [MySQL] - 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: Loading job [MySQL] (
/showthread.php?tid=614786)
Loading job [MySQL] -
TheBigFive - 12.08.2016
Here's my code:
http://pastebin.com/QaYhw2KR
I need suggestion how to improve the current job system I have as I am new to pawn. But my problem right now is that the job is not being loaded upon restart. I have actors that are supposed to be created when jobs are loaded. Actors spawn when I create the jobs, but they aren't loading after a restart. This is my code, and OnGameModeInit I added LoadJobs();
How does this work with the actor by the way? Any way I can use "InRangeOfActor" ish thing to make a person able to use a command once the player is close to one of the actors and get the job id?
Using izcmd sscanf streamer.
Re: Loading job [MySQL] -
justjamie - 13.08.2016
The LoadJobs has to be a function
(public LoadJobs etc)
Then in the query
(mysql_function_query(connection, query, true, "", "")
you have to use this:
mysql_function_query(connection, query, true, "LoadJobs", "");
Example:
PHP код:
forward LoadingJobs();
public LoadingJobs()
{
if(cache_num_rows)
{
while(totaljobs < cache_num_rows)
{
id = cache_get_row_int(totaljobs, 0);
jobData[id][jobtype] = cache_get_row_int(totaljobs, 1);
cache_get_row(totaljobs, 2, jobData[id][jobname], connection, 24);
jobData[id][jobposx] = cache_get_row_float(totaljobs, 3);
jobData[id][jobposy] = cache_get_row_float(totaljobs, 4);
jobData[id][jobposz] = cache_get_row_float(totaljobs, 5);
jobData[id][jobposa] = cache_get_row_float(totaljobs, 6);
jobData[id][jobworld] = cache_get_row_int(totaljobs, 7);
jobData[id][actorskin] = cache_get_row_int(totaljobs, 8);
CreateActor(jobData[id][actorskin], jobData[id][jobposx], jobData[id][jobposy], jobData[id][jobposz], jobData[id][jobposa]);
totaljobs++;
printf("%d jobs loaded", totaljobs);
}
}
return 1;
}
stock LoadJobs()
{
format(query, sizeof(query), "SELECT * FROM `jobs`");
mysql_function_query(connection, query, true, "LoadingJobs", "");
return 1;
}