First put this in your pawno includes, it's dini file functions which you'll be using.
http://dracoblue.net/download-release/35/dini_1_6.zip
Put this on the top of your script under includes.
PHP код:
new DMV[MAX_PLAYERS]; // We will use this to set every single player's DMV to 1 or 0 according to the file
Now you have to make the command, put this under OnPlayerCommandText
PHP код:
if (strcmp("/dmv", cmdtext, true, 4) == 0) // The command
{
if(!dini_Exists("dmv.cfg") dini_Create("dmv.cfg") // If the file is not in your scriptfiles folder the script will create it
if(dini_Int("dmv.cfg", "dmv") == 0) // if dmv in the file is = 0
{
dini_IntSet("dmv.cfg", "dmv", "1"); // Set dmv=1 in the file
SendClientMessage(playerid, 0xFFFFFFFF, "You have set DMV to 1.");
}
else if(dini_Int("dmv.cfg", "dmv") == 1) // if dmv in the file is = 1
{
dini_IntSet("dmv.cfg", "dmv", "0"); // Set dmv=0 in the file
SendClientMessage(playerid, 0xFFFFFFFF, "You have set DMV to 0.");
}
for(new i=0; i<MAX_PLAYERS; i++) // loop to set connected players DMV to the value from file
{
if(IsPlayerConnected(i))
{
DMV[i] = dini_Int("dmv.cfg", "dmv");
}
}
return 1;
}
Put this under OnPlayerConnect
PHP код:
DMV[playerid] = dini_Int("dmv.cfg", "dmv"); // Set the player's DMV to the value in file
if(dini_Int("dmv.cfg", "dmv") == 0) // if dmv in the file is = 0
{
SendClientMessage(playerid, 0xFFFFFFFF, "Your DMV is 1.");
}
else if(dini_Int("dmv.cfg", "dmv") == 1) // if dmv in the file is = 1
{
SendClientMessage(playerid, 0xFFFFFFFF, "Your DMV is 1.");
}
If you get any error on compiling tell me, written it directly into the browser.