23.12.2009, 08:21
OK, well i have a big problem here =/
I m trying to reset the variable "vowner" and "vowned" to 0 in ALL of the user files, i am trying to make the server:
1. Add the username to a list in the acounts folder.
2. Read the list and change the variables for all the users in the list
Sounds easy, but i cant get it figured out, here is what i have so far:
In the register command
This is called to change the variables:
EDIT: Solved with:
I m trying to reset the variable "vowner" and "vowned" to 0 in ALL of the user files, i am trying to make the server:
1. Add the username to a list in the acounts folder.
2. Read the list and change the variables for all the users in the list
Sounds easy, but i cant get it figured out, here is what i have so far:
In the register command
pawn Код:
new filestring[256];
new File: pvfile = fopen("/ladmin/users/players.txt", io_write);
format(filestring, sizeof(filestring), "%s\n", PlayerInfo[playerid][name] );
fwrite(pvfile, filestring);
fclose(pvfile);
pawn Код:
stock aresetallcar()
{
for(new i = 1; i < MAX_PLAYERS; i++){
if(IsPlayerConnected(i)) {
PlayerInfo[i][vowned] = 0;
PlayerInfo[i][vowner] = 0;
SavePlayer(i);
}
}
for(new v = 1; v < MAX_VEHICLES; v++){
SetVehicleToRespawn(v);
SetVehicleVirtualWorld(v,10);
EraseVehicle(v);
}
if(fexist("/ladmin/users/players.txt")) {
new rvpname[MAX_PLAYER_NAME];
new SplitDiv[99][MAX_VEHICLES];
new filestring[256];
new File: file = fopen("/ladmin/users/players.txt", io_read);
if (file) {
fread(file, filestring);
split(filestring, SplitDiv, ',');
strmid(rvpname, SplitDiv[0], 0, strlen(SplitDiv[0]), 255);
}
fclose(file);
ResetOfflinePlayerFile(rvpname);
}
return 1;
}
pawn Код:
stock aresetallcar()
{
for(new v = 0; v < MAX_VEHICLES; v++){
DestroyVehicle(v);
}
for(new p = 0; p < MAX_PLAYERS; p++){
if(IsPlayerConnected(p) == 1) {
PlayerInfo[p][vowner] = 0;
PlayerInfo[p][vowned] = 0;
}
}
new buf[64], i;
i = 0;
while(ffind("ladmin/users/*.sav", buf, sizeof(buf), i))
{
new fname[MAX_STRING];
format(fname,sizeof(fname),"ladmin/users/%s",buf);
dini_IntSet(fname, "vowner", 0);
dini_IntSet(fname, "vowned", 0);
}
}