20.04.2012, 14:01
well yeah it DOES saves it now... but not to the right file... cuz when i create building a race it... wait let me show to codes i dont know how to explain it...
the buildrace command:
showdialog function:
the ondialogresponse:
but i want it that it saves during the building it saves the RaceMode to the file of the racefile... so now it saves the racemode to a NEW file but i want it to get written while building to the new file in scriptfiles where also the other race settings are saved... so like the checkpoints and other things i want it that it also adds in that file the RaceMode=0/1/2 and not that it saves to a NEW file... pls anyone knows how to do this? as i said before this is first time i work with saving systems and i dont really understand it yet and i have to learn it... so pls anyone help to fix this? EVERYONE WHO HELPS GETS REP+!!! REALLY i NEED your help
the buildrace command:
pawn Код:
CMD:buildrace(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> You are not an administrator!");
if(BuildRace != 0) return SendClientMessage(playerid, RED, "<!> There's already someone building a race!");
if(RaceBusy == 0x01) return SendClientMessage(playerid, RED, "<!> Wait first till race ends!");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "<!> Please leave your vehicle first!");
BuildRace = playerid+1;
ShowDialog(playerid, 599);
return 1;
}
pawn Код:
function ShowDialog(playerid, dialogid)
{
switch(dialogid)
{
case 599: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, CreateCaption("Build New Race"), "\
Bike Race\nCar Race\nCar And Bike Race", "Next", "Exit");
case 600: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 1/4)"), "\
Step 1:\n\
********\n\
Welcome to wizard 'Build New Race'.\n\
Before getting started, I need to know the name (e.g. SFRace) of the to save it under.\n\n\
>> Give the NAME below and press 'Next' to continue.", "Next", "Back");
case 601: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 1/4)"), "\
ERROR: Name too short or too long! (min. 1 - max. 20)\n\n\n\
Step 1:\n\
********\n\
Welcome to wizard 'Build New Race'.\n\
Before getting started, I need to know the name (e.g. SFRace) of the to save it under.\n\n\
>> Give the NAME below and press 'Next' to continue.", "Next", "Back");
case 602: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 2/4)"), "\
Step 2:\n\
********\n\
Please give the ID or NAME of the vehicle that's going to be used to create the race you are creating now.\n\n\
>> Give the ID or NAME of the vehicle below and press 'Next' to continue. 'Back' to change something.", "Next", "Back");
case 603: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 2/4)"), "\
ERROR: Invalid Vehilce ID/Name\n\n\n\
Step 2:\n\
********\n\
Please give the ID or NAME of the vehicle that's going to be used to create the race you are creating now.\n\n\
>> Give the ID or NAME of the vehicle below and press 'Next' to continue. 'Back' to change something.", "Next", "Back");
case 604: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Build New Race (Step 3/4)"),
"\
Step 3:\n\
********\n\
We are almost done! Now go to the start line where the first and second car should stand.\n\
Note: When you click 'OK' you will be free. Use 'KEY_FIRE' to set the first position and second position.\n\
Note: After you got these positions you will automaticly see a dialog to continue the wizard.\n\n\
>> Press 'OK' to do the things above. 'Back' to change something.", "OK", "Back");
case 605: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Build New Race (Step 4/4)"),
"\
Step 4:\n\
********\n\
Welcome to the last stap. In this stap you have to set the checkpoints; so if you click 'OK' you can set the checkpoints.\n\
You can set the checkpoints with 'KEY_FIRE'. Each checkpoint you set will save.\n\
You have to press 'ENTER' button when you're done with everything. You race is aviable then!\n\n\
>> Press 'OK' to do the things above. 'Back' to change something.", "OK", "Back");
case 606: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Build New Race (Done)"),
"\
You have created your race and it's ready to use now.\n\n\
>> Press 'Finish' to finish. 'Exit' - Has no effect.", "Finish", "Exit");
}
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 599:
{
if(!response) return BuildRace = 0;
new rFile[256];
format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", RaceName);
if(!dini_Exists(rFile)) return dini_Create(rFile);
switch(listitem)
{
case 0:
{
RaceMode = 0;
dini_IntSet(rFile,"RaceMode", RaceMode=0);
}
case 1:
{
RaceMode = 1;
dini_IntSet(rFile, "RaceMode", RaceMode=1);
}
case 2:
{
RaceMode = 2;
dini_IntSet(rFile,"RaceMode", RaceMode2);
}
}
ShowDialog(playerid, 600);
}
case 600..601:
{
if(!response) return ShowDialog(playerid, 599);
if(!strlen(inputtext)) return ShowDialog(playerid, 601);
if(strlen(inputtext) < 1 || strlen(inputtext) > 20) return ShowDialog(playerid, 601);
strmid(BuildName, inputtext, 0, strlen(inputtext), sizeof(BuildName));
ShowDialog(playerid, 602);
}
case 602..603:
{
if(!response) return ShowDialog(playerid, 600);
if(!strlen(inputtext)) return ShowDialog(playerid, 603);
if(isNumeric(inputtext))
{
if(!IsValidVehicle(strval(inputtext))) return ShowDialog(playerid, 603);
new
Float: pPos[4]
;
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
GetPlayerFacingAngle(playerid, pPos[3]);
BuildModeVID = strval(inputtext);
BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
BuildVehicle = CreateVehicle(strval(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
PutPlayerInVehicle(playerid, BuildVehicle, 0);
BuildCreatedVehicle = 0x01;
ShowDialog(playerid, 604);
}
else
{
if(!IsValidVehicle(ReturnVehicleID(inputtext))) return ShowDialog(playerid, 603);
new
Float: pPos[4]
;
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
GetPlayerFacingAngle(playerid, pPos[3]);
BuildModeVID = ReturnVehicleID(inputtext);
BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
BuildVehicle = CreateVehicle(ReturnVehicleID(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
PutPlayerInVehicle(playerid, BuildVehicle, 0);
BuildCreatedVehicle = 0x01;
ShowDialog(playerid, 604);
}
}
case 604:
{
if(!response) return ShowDialog(playerid, 602);
SendClientMessage(playerid, GREEN, ">> Go to the start line on the left road and press 'KEY_FIRE' and do the same with the right road block.");
SendClientMessage(playerid, GREEN, " - When this is done, you will see a dialog to continue.");
BuildVehPosCount = 0;
BuildTakeVehPos = true;
}
case 605:
{
if(!response) return ShowDialog(playerid, 604);
SendClientMessage(playerid, GREEN, ">> Start taking checkpoints now by clicking 'KEY_FIRE'.");
SendClientMessage(playerid, GREEN, " - IMPORTANT: Press 'ENTER' when you're done with the checkpoints! If it doesn't react press again and again.");
BuildCheckPointCount = 0;
BuildTakeCheckpoints = true;
}
case 606:
{
if(!response) return ShowDialog(playerid, 606);
BuildRace = 0;
BuildCheckPointCount = 0;
BuildVehPosCount = 0;
BuildTakeCheckpoints = false;
BuildTakeVehPos = false;
BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
}
}
return 1;
}