[FilterScript] [Dynamic] NOS and Repair creation [For Derby or DD/DM servers]
#1

Hi!

It has passed a long time since last time I have released something and I thought of doing something special instead of things that have been done before. I don't know if I am right, but I haven't seen something like this released on the forums before, if I'm wrong, please correct me. In the meanwhile, let's continue with the explanations


What is this?!

Some of you might not even know what all this thing is, well, it is pretty easy. There are some kind of Derby or DD/DM servers. These servers use repair and nos to repair vehicles (MTA style). Eventhough there's an XML converter which has been used before, in order to convert MTA maps using all of its components (repair, nos etc), I thought I could do this in order to make things easier, as it is not something hard.

How to use?

I've tried to keep the things easy for both sides (scripter and user). The script is made in total of 2 commands.

• /create - A dialog containing what you want to create will show up (Nos, repair, nos and repair). When you chose one of them, the 3DText will get created on sight for each category. Either way, IT WONT WORK. As soon as you create something, you will get a TXT file created on your 'scriptfiles' folder. There, you will find:
- repair.txt ; - nos.txt ; - repairandnos.txt (not sure if that's how the last is named)

The code will look like:
pawn Код:
Create3DTextLabel("[[ Repair and Nitro ]]",0x4B00B0AA,119.90, -76.18, 1.57,30.0,1);

if(IsPlayerInRangeOfPoint(playerid, 3, 119.90,-76.18, 1.57))return AddVehcileComponent(GetPlayerVehicleID(playerid), 1010), RepairVehicle(GetPlayerVehicleID(playerid));
This code:
pawn Код:
Create3DTextLabel("[[ Repair and Nitro ]]",0x4B00B0AA,119.90, -76.18, 1.57,30.0,1);
Shall be added under OnGameModeInIt, like a normal 3DText, while,
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3, 119.90,-76.18, 1.57))return AddVehcileComponent(GetPlayerVehicleID(playerid), 1010), RepairVehicle(GetPlayerVehicleID(playerid));
Shall be added under "OnPlayerUpdate", or an timer running every second, eventhough it might not be 'that' accurate.

• /cc - This is the same feature as Repair and Nos creation together, it was just for some BETA testing in-case the dialogs wouldn't work.


Download
pawn Код:
#include <a_samp>

stock fcreate(filename[])
{
    if (fexist(filename)){return false;}
    new File:fhandle = fopen(filename,io_write);
    fclose(fhandle);
    return true;
}

public OnFilterScriptInit()
{
    print("\n------------------------------------------");
    print(" Dynamic Repair and NOS creation in-game - loaded ");
    print("------------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/create", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid)) {
            ShowPlayerDialog(playerid,3335,DIALOG_STYLE_LIST,"{FFFFFF}What would you like to create?","NOS & Repair\nNOS only\nRepair only","Add","Cancel");
        }
        else
        {
            SendClientMessage(playerid,0xFF0000FF,"You are not an Admin.");
        }
        return 1;
    }
    if(strcmp("/cc", cmdtext, true, 3) == 0)
    {
        new File:file, string[2000];
        if(!fexist("RepairAndNos.txt")) return fcreate("RepairAndNos.txt");
        file=fopen("RepairAndNos.txt",io_append);
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        format(string, 2000, "%s\r\nCreate3DTextLabel(\"[[ Repair and Nitro ]]\",0x4B00B0AA,%.2f, %.2f, %.2f,30.0,1);\n", string, x, y, z);
        format(string, 2000, "%s\r\nif(IsPlayerInRangeOfPoint(playerid, 3, %.2f,%.2f, %.2f))return AddVehcileComponent(GetPlayerVehicleID(playerid), 1010), RepairVehicle(GetPlayerVehicleID(playerid));\n", string ,x, y, z);
        Create3DTextLabel("[[ Repair and Nitro ]]",0xFF0000FF,x,y,z,30.0,0,1);
        fwrite(file,string);
        fwrite(file,"\r\n");
        fclose(file);
        return 1;
    }

    return 0;
}


//-------------------------------------------------------------------------------------------------------------

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[2000];
    if(dialogid == 3335)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    new File:nosrepair;
                    if(!fexist("RepairAndNos.txt")) return fcreate("RepairAndNos.txt");
                    nosrepair=fopen("RepairAndNos.txt",io_append);
                    new Float:x,Float:y,Float:z;
                    GetPlayerPos(playerid,x,y,z);
                    format(string, 2000, "%s\r\nCreate3DTextLabel(\"[[ Repair and Nitro ]]\",0x4B00B0AA,%.2f, %.2f, %.2f,30.0,1);\n", string, x, y, z);
                    format(string, 2000, "%s\r\nif(IsPlayerInRangeOfPoint(playerid, 3, %.2f,%.2f, %.2f))return AddVehcileComponent(GetPlayerVehicleID(playerid), 1010), RepairVehicle(GetPlayerVehicleID(playerid));\n", string ,x, y, z);
                    Create3DTextLabel("[[ Repair and Nitro ]]",0xFF0000FF,x,y,z,30.0,0,1);
                    fwrite(nosrepair,string);
                    fwrite(nosrepair,"\r\n");
                    fclose(nosrepair);
                }
                case 1:
                {
                    new File:nos;
                    if(!fexist("Nos.txt")) return fcreate("Nos.txt");
                    nos=fopen("Nos.txt",io_append);
                    new Float:x,Float:y,Float:z;
                    GetPlayerPos(playerid,x,y,z);
                    format(string, 2000, "%s\r\nCreate3DTextLabel(\"[[ Repair and Nitro ]]\",0x4B00B0AA,%.2f, %.2f, %.2f,30.0,1);\n", string, x, y, z);
                    format(string, 2000, "%s\r\nif(IsPlayerInRangeOfPoint(playerid, 3, %.2f,%.2f, %.2f))return AddVehcileComponent(GetPlayerVehicleID(playerid))", 1010);
                    Create3DTextLabel("[[ Nitro ]]",0xFF0000FF,x,y,z,30.0,0,1);
                    fwrite(nos,string);
                    fwrite(nos,"\r\n");
                    fclose(nos);
                }
                case 2:
                {
                    new File:repair;
                    if(!fexist("Repair.txt")) return fcreate("Repair.txt");
                    repair=fopen("Repair.txt",io_append);
                    new Float:x,Float:y,Float:z;
                    GetPlayerPos(playerid,x,y,z);
                    format(string, 2000, "%s\r\nCreate3DTextLabel(\"[[ Repair and Nitro ]]\",0x4B00B0AA,%.2f, %.2f, %.2f,30.0,1);\n", string, x, y, z);
                    format(string, 2000, "%s\r\nif(IsPlayerInRangeOfPoint(playerid, 3, %.2f,%.2f, %.2f))return RepairVehicle(GetPlayerVehicleID(playerid));\n", string ,x, y, z);
                    Create3DTextLabel("[[ Repair ]]",0xFF0000FF,x,y,z,30.0,0,1);
                    fwrite(repair,string);
                    fwrite(repair,"\r\n");
                    fclose(repair);
                }
            }
        }
    }
    return 1;
}
F.A.Q

Q: The dialog wont show up?
A: Try changing dialog ID's, you might have another dialog with same ID on your main script

Q: The 3DText showed up, but it ain't work yet.
A: Have you added the "IsPlayerInRangeOfPoint" that is found on the .txt file that is created after using the command? If not, add that. (read up for more information)

Q:
Where can I get support?
A: Just post down here, I will answer as soon as I check it out



________________________________________

I hope this helps any of you trying to get a cool server up in the near future. I know this is not something special, but I just tried to do something to help the community. Feedback is appreciated.
Reply
#2

Eww strcmp why not zcmd + sscanf?
Reply
#3

So there's no need to use many includes, it is easy to run system, no need to charge it up with other includes.
Reply
#4

not bad, make a zcmd version though, people will complain about it.
Reply
#5

Thanks for the feedback, appreciated.
Reply
#6

Bump
Reply
#7

Nice work
Reply
#8

great job keep it up
Reply
#9

bad work look this https://www.youtube.com/watch?v=hUIDs_0agxE https://www.youtube.com/watch?v=DRWmtBpxlWk
Reply
#10

That's a gamemode, this is a filterscript. This is just the system to make the nos & repair work in-game, while the gamemode converts the MTA .xml file into a readable system by pawno.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)