Best way to store commands - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Best way to store commands (
/showthread.php?tid=257429)
Best way to store commands -
ScottCFR - 25.05.2011
What's the best way I can store commands that are loaded from a mysql database. Currently it's querying the DB when the command is processed. In the past couple days I've realised how inefficient this is. So, what's the best way to go about storing these when the server loads. I'm thinking an array, but I'm unsure how to do it.
Re: Best way to store commands -
ScottCFR - 25.05.2011
That's what I meant, I coded the commands into my GM and use mysql to store command levels. I make a query on every command to check the level, I noticed it used a high memory load when 3 - 4 people are using these commands at once. So, yes I need a way to store the command level.
Re: Best way to store commands -
futuretrucker - 26.05.2011
If I understand what your saying make a enum like this.
pawn Код:
enum User
{
Money,
Level
}
new pInfo[playerid][User];
Then when the player connects use sscanf to store the values collected. Once that is done you can just do something like
pawn Код:
COMMAND:cmd(playerid,params[])
{
if(pInfo[playerid][Level] == 0)
{
SendClientMessage(playerid, red, "You are not a admin!");
}
else if(pInfo[playerid][Level] == 1)
{
SendClientMessage(playerid, green, "/goto, /healall");
}
return 1;
}
Re: Best way to store commands -
ylleron - 26.05.2011
yes, i recommended you YCMD too. I have used it in my gamemode and it's really good, combination with sscanf is the best