(HELP) Re-Write file
#1

Hey, i making a driving license test for my server it's sgt's driving test and i did do it for LS all is fine, i have it already, but it's filterscript and when i do the test. I have driving license but, if i type /licenses (id) it's not showing PASSED, it's showing NOT PASSED, because it's writing in CarLicenses(I made this folder) folder and if i change writing in users folder , it's not passed, but i have already a License after login. How i can do, that if i do a license test, get license and it will be passed in /licenses (id) ? Please I don't know how to do that, look at script:

Quote:

/*
This Filterscript was created by Sgt (Sascha).
It was made for SA-MP.com.
Everyone may use this script, however you may not claim it as your own!
Editing or removing this credit lines is strictly forbidden!
*/
#define FILTERSCRIPT

#include <a_samp>

#define COLOR_RED 0xAC0404AA
#define COLOR_GREEN 0x39CC00AA
#define COLOR_GREY 0x7F7F7FAA

enum PlayerSaves
{
InPickUp,
Step,
Vehicle,
Float:VH,
CP
}

new PlayerData[MAX_PLAYERS][PlayerSaves];
new sgt_vehicle[MAX_VEHICLES];
new sgt_pickup;

new FloatLCP[][3] =
{
{2094.2458,-1757.2183,13.2750},
{2114.8501,-1547.3146,24.4346},
{2093.0437,-1383.5345,23.7028},
{2074.2417,-1222.6780,23.6977},
{2011.9783,-1133.2168,24.8681},
{1967.5641,-1191.1130,25.6288},
{1899.7421,-1259.0839,13.2739},
{1778.6519,-1281.2861,13.3479},
{1712.1005,-1349.0924,13.2579},
{1660.6407,-1437.3768,13.2579},
{1449.2258,-1479.7397,13.2467},
{1426.7952,-1642.2052,13.2524},
{1531.7705,-1734.7625,13.2622},
{1878.1281,-1753.6519,13.2579},
{2062.4692,-1754.5667,13.2658},
{2062.0320,-1918.8903,13.4219}

};

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("Driving License v0.6 by Sgt aka Sascha");
print("--------------------------------------\n");

sgt_pickup = CreatePickup(1239, 23, 1491.2736,1307.4366,1093.2891, -1);
return 1;
}

public OnFilterScriptExit()
{
print("\n--------------------------------------");
print("Shutting down Sgt's Driving License v0.6");
print("--------------------------------------\n");
return 1;
}

public OnPlayerSpawn(playerid)
{
PlayerData[playerid][InPickUp] = 0;
PlayerData[playerid][Step] = 0;
PlayerData[playerid][CP] = -1;
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
if(PlayerData[playerid][Step] > 1)
{
SendClientMessage(playerid, COLOR_RED, "You've failed your driving test.");
}
return 1;
}

public OnVehicleSpawn(vehicleid)
{
if(sgt_vehicle[vehicleid] == 1)
{
SetVehicleToRespawn(vehicleid);
}
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
if(sgt_vehicle[vehicleid] == 1)
{
SetVehicleToRespawn(vehicleid);
}
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
if(PlayerData[playerid][Step] >= 1)
{
PlayerData[playerid][Vehicle] = GetPlayerVehicleID(playerid);
GetVehicleHealth(GetPlayerVehicleID(playerid), PlayerData[playerid][VH]);
SendClientMessage(playerid, COLOR_GREEN, "Drive to the first checkpoint and follow the following ones");
PlayerData[playerid][Step] = 2;
SetPlayerRaceCheckpoint(playerid, 0, 2083.5579,-1914.2047,13.2578, 2094.2458,-1757.2183,13.2750 , 3.00);
PlayerData[playerid][CP] = 0;
return 1;
}
else if(PlayerData[playerid][Step] == 0)
{
if(!IsDLFree(GetPlayerVehicleID(playerid)))
{
new string[100], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "users/%s.ini", pname);
if(!fexist(string))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED, "You need a driving license to drive the vehicle! ");
}
}
}
}
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
if(PlayerData[playerid][Step] == 1 && !IsPlayerInAnyVehicle(playerid))
{
new v = CreateVehicle(0,0,0.0,0,0.0,0,0,0);
sgt_vehicle[v] = 1;
SendClientMessage(playerid, COLOR_GREEN, "Get into the vehicle and follow the checkpoints.");
DisablePlayerCheckpoint(playerid);
}
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == PlayerData[playerid][Vehicle] && PlayerData[playerid][Step] >= 2)
{
if(PlayerData[playerid][CP] <= 14)
{
new n = PlayerData[playerid][CP];
new n2 = PlayerData[playerid][CP] + 1;
SetPlayerRaceCheckpoint(playerid, 0, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n2][0], DLCP[n2][1], DLCP[n2][2], 2.00);
PlayerData[playerid][CP]++;
}
else if(PlayerData[playerid][CP] == 15)
{
new n = PlayerData[playerid][CP];
SetPlayerRaceCheckpoint(playerid, 1, DLCP[n][0], DLCP[n][1], DLCP[n][2], DLCP[n][0], DLCP[n][1], DLCP[n][2], 2.00);
PlayerData[playerid][CP]++;
}
else
{
DisablePlayerRaceCheckpoint(playerid);
new v = GetPlayerVehicleID(playerid);
new Float:vhp;
GetVehicleHealth(v, vhp);
new Floatif = ((PlayerData[playerid][VH] / 10) - (vhp / 10));
PlayerData[playerid][CP] = -1;
if(Dif <= 2)
{
ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "Congratulations!\nYou have passed the test and are now\nthe owner of a driving license!", "OK", "");
SetPVarInt(playerid, "users", 1);
}
else
{
ShowPlayerDialog(playerid, 138, DIALOG_STYLE_MSGBOX, "Driving License", "We are sorry.\nYou have failed the driving test.\nPlease try it again, later.", "OK", "");
SetPVarInt(playerid, "users", 2);
}
}
}
return 1;
}



public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == sgt_pickup)
{
if(PlayerData[playerid][InPickUp] == 0)
{
PlayerData[playerid][InPickUp] = 1;
SetTimerEx("OnPlayerLeavePickUp", 5000, false, "i", playerid);
new pname[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "users/%s.ini", pname);
if(fexist(string)) return SendClientMessage(playerid, COLOR_GREY, "You already have a driving license.");
else ShowPlayerDialog(playerid, 137, DIALOG_STYLE_MSGBOX, "Driving License", "Do you wanna Driving License?, \nclick onto 'Start Test' \nit costs 1000 dollars", "Start Test", "");
}
}
return 1;
}

forward OnPlayerLeavePickUp(playerid);
public OnPlayerLeavePickUp(playerid)
{
PlayerData[playerid][InPickUp] = 0;
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 137)
{
if(response)
{
PlayerData[playerid][Step] = 1;
GivePlayerMoney (playerid, -1000);
SendClientMessage(playerid, COLOR_GREY, "You paid 1000 dollars. Get out of this bulding to start test.");
SetPlayerCheckpoint(playerid, 2046.8928,-1908.0372,13.5469,280.0000);
}
}
else if(dialogid == 13
{
if(GetPVarInt(playerid, "users") == 2)
{
SetPVarInt(playerid, "users", 0);
PlayerData[playerid][Step] = 0;
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(PlayerData[playerid][Vehicle]);
}
else if(GetPVarInt(playerid, "users") == 1)
{
new pname[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "users/%s.ini", pname);
new Filegt_file = fopen(string, io_write);
new day, year, month;
getdate(year, month, day);
format(string, sizeof(string), "CarLic=1", pname, day, month, year);
fwrite(sgt_file, string);
fclose(sgt_file);
PlayerData[playerid][Step] = 0;
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(PlayerData[playerid][Vehicle]);
}
}
return 1;
}

stock IsDLFree(vehicleid)
{
new m = GetVehicleModel(vehicleid);
if(m == 509 || m == 481 || m == 510 || m == 462 || m == 448 || m == 592 || m == 577 || m == 511 || m == 512
|| m == 593 || m == 520 || m == 448 || m == 553 || m == 476 || m == 519 || m == 460 || m == 513 || m == 548
|| m == 425 || m == 417 || m == 487 || m == 488 || m == 497 || m == 469 || m == 563 || m == 447)
{
return 1;
}
return 0;
}



I need that in users folder it will change CarLic=0 on CarLic=1
But i dont how to do that... please guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)