CMD:cashtest(playerid, params[]) //the command
{
User[playerid][USER_MONEY] += 1000000;
//User can also be pInfo and USER_MONEY can be pMoney (depends on what you set)
GivePlayerMoney(playerid, 1000000);
//gives the player the in-game money wich is then stored in the database (at USER_MONEY)
return 1;
}
CMD:setkills(playerid, params[])
{
if(User[playerid][USER_ADMIN] >= 5)
//we check if the user is admin level 5 or higher
{
new targetid ,amount;
if(sscanf(params, "ud", targetid, amount)) return SendClientMessage(playerid, COL_WHITE, "/setkills [playerid] [kills]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COL_WHITE, "Player is not online");
User[playerid][USER_KILLS] = amount;
//gets the variable amount and sets it to the entered value, so /setkills [id] [value = amount]
}
else
{
SendClientMessage(playerid, COL_RED, "You are not a administrator!");
}
return 1;
}
CMD:setdeaths(playerid, params[])
{
if(User[playerid][USER_ADMIN] >= 5)
//we check if the user is admin level 5 or higher
{
new targetid ,amount;
if(sscanf(params, "ud", targetid, amount)) return SendClientMessage(playerid, COL_WHITE, "/setdeaths [playerid] [deaths]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COL_WHITE, "Player is not online");
User[playerid][USER_DEATHS] = amount;
//gets the variable amount and sets it to the entered value, so /setdeaths [id] [value = amount]
}
else
{
SendClientMessage(playerid, COL_RED, "You are not a administrator!");
}
return 1;
}
CMD:setscore(playerid, params[])
{
if(User[playerid][USER_ADMIN] >= 5)
//we check if the user is admin level 5 or higher
{
new targetid ,amount;
if(sscanf(params, "ud", targetid, amount)) return SendClientMessage(playerid, COL_WHITE, "/setscore [playerid] [score]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COL_WHITE, "Player is not online");
User[playerid][USER_SCORE] = amount;
//gets the variable amount and sets it to the entered value, so /setscore [id] [value = amount]
}
else
{
SendClientMessage(playerid, COL_RED, "You are not a administrator!");
}
return 1;
}
CMD:givemoney(playerid, params[])
{
if(User[playerid][USER_ADMIN] >= 5)
//we check if the user is admin level 5 or higher
{
new targetid, amount;
if(sscanf(params, "ud", targetid, amount)) return SendClientMessage(playerid, COL_WHITE, "/givemoney [playerid] [money]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COL_WHITE, "Player is not online");
if(amount < 0 || amount > 30000) return SendClientMessage(playerid, COL_WHITE, "You can only give a maximum amount of $30 000");
//here we check if the user types a amount between 0 and 30000, if he exceeds this value he will recieve a message that he can only give a maximum of 300000
User[playerid][USER_MONEY] += amount;
//here we get the value of the givin amount again but this time we put: plus and equal
GivePlayerMoney(playerid, amount);
//and finally we give the player the amount (value) that we put in our params of the command!
}
else
{
SendClientMessage(playerid, COL_RED, "You are not a administrator!");
}
return 1;
}
CMD:setadmin(playerid,params[])
{
if(User[playerid][USER_ADMIN] >= 6 || IsPlayerAdmin(playerid))
//we check if he has the maximum admin rank or if he is a rcon admin
{
new targetid, level;
if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, COL_WHITE,"/setadmin [playerid] [level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COL_WHITE, "Player is not online");
if(level < 0 || level > 6) return SendClientMessage(playerid, COL_WHITE, "You can only set admin levels from 1 to 6!");
//we check if he enters a value between 0 and 6 otherwise he will get a error saying only admin levels between 1 and 6.
User[targetid][USER_ADMIN] = level;
//we set the variable level to the value we gave in the params and it saves it in the database
}
else
{
SendClientMessage(playerid, COL_RED, "You are not a administrator!");
}
return 1;
}
Well you can't call them "SQL commands"(Commands with SQL) becouse you do not perform any query in that commands.. they are just script that change some variables..
EDIT: Anyway forgot to say.. good |
This has nothing to do with SQL at all.
http://en.wikipedia.org/wiki/SQL |
Thank you!
Nothing to do with SQL at all? please... you obviously need a SQLite database to use these commands. You dont always have to be such wiseacre. Anyway thanks for the replies! |
You must be missing some code or something there is no query functions or anything related to SQLite in your tutorial....or did you confuse sscanf with SQLite?
|
There is no reference to any saving or loading anywhere in your tutorial whatsoever.
|
I'm not missing any code and I don't really understand why everyone is making such a big deal out of it.
I made a tutorial on how to manage and change you'r SQLite database using these commands. As I said it obviously has to do with the SQLite since its detecting if you are a specific admin level and then change a specific value IN the SQLite database. Yes I understand that i'm not changing any query's or anything like that but the fact that people say it has nothing to do with SQLite is just invalid (atleast in my opinion). |