[Help] Dynamic Turf System
#1

Hello. Today I felt like scripting so I went into my old script and noticed I failed to do something: Create a turf dynamically. So today, I tried again and I still failed. So I turned to my fellow SA:MP community for help.

Basically, when you do /createturf and hit KEY_FIRE once, the turf file would create. However, it should be dynamic so that means that it should write to a file thats number is 1. But how do I get it so that if I am creating say, turf 4, the file will say 4 instead of 1? If that makes any since. Then, the X position would write to a dini file. Hitting fire again, their Y position would go in, so on and so forth. Here is the /createturf command:

pawn Код:
CMD:createturf(playerid)
{
if(Admin[playerid] >= 4)
{
    if(GangZoneModify[playerid] == 0)
    {
    SendClientMessage(playerid, COLOR_WHITE, "You have begain to create a turf. Hit 'FIRE' to select each position.");
    GangZoneModify[playerid] = 1;
    }
    else if(GangZoneModify[playerid] <= 1)
    {
    SendClientMessage(playerid, COLOR_WHITE, "You are already creating a turf, you can't create a new one!");
    }
    return 1;
}
return SendClientMessage(playerid, COLOR_NEWBIE, "You do not have permissions to preform this command!");
}
I've explained what I would like help with through the PAWN comment system:

pawn Код:
//This is under OnPlayerKeyStateChange
if(GangZoneModify[playerid] == 1 && (newkeys & KEY_FIRE))
    {
        new Float:x, Float:y, Float:z;
        // here it would create the file '1' for turf 1 using dini
        // here it would add a line called X1=
        GetPlayerPos(playerid, x, y, z);
        // here it would write to the file the players x coordinate on line X1=0.000000 (or whatever the current player coordinates are)
        GangZoneModify[playerid] = 2;
        SendClientMessage(playerid, COLOR_WHITE, "Position one successfully saved, find position two and hit 'FIRE' when ready!");
    }
    if(GangZoneModify[playerid] == 2 && (newkeys & KEY_FIRE))
    {
        new Float:x, Float:y, Float:z;
        // here it would add a line called Y1= using dini
        GetPlayerPos(playerid, x, y, z);
        // here it would write to the file the players y coordinate on line Y1=0.000000 (or whatever the current player coordinates are)
        GangZoneModify[playerid] = 3;
        SendClientMessage(playerid, COLOR_WHITE, "Position two successfully saved, find position two and hit 'FIRE' when ready!");
    }
    if(GangZoneModify[playerid] == 3 && (newkeys & KEY_FIRE))
    {
        new Float:x, Float:y, Float:z;
        // here it would add a line called X2= using dini
        GetPlayerPos(playerid, x, y, z);
        // here it would write to the file the players x coordinate on line X2=0.000000 (or whatever the current player coordinates are)
        GangZoneModify[playerid] = 4;
        SendClientMessage(playerid, COLOR_WHITE, "Position three successfully saved, find position three and hit 'FIRE' when ready!");
    }
    if(GangZoneModify[playerid] == 4 && (newkeys & KEY_FIRE))
    {
        new Float:x, Float:y, Float:z;
        // here it would add a line called Y2= using dini
        GetPlayerPos(playerid, x, y, z);
        // here it would write to the file the players y coordinate on line Y2=0.000000 (or whatever the current player coordinates are)
        GangZoneModify[playerid] = 5;
        SendClientMessage(playerid, COLOR_WHITE, "Position three successfully saved, type '/continueturf' when ready!");
    }
So, to be a little clear about what I would like here we go:

When the player does /createturf, I want it to send that client message. No problem, that is done. However, when they hit 'FIRE' for the first time, it should create a numeric file that is +1 from the last one. So say I have created turf 1 and I wanted to create turf 2. When I do /createturf and hit 'FIRE' it would check the previous file and if it was 1, in this case it is, it would create file 2. If it was 2, it would create file 3, so on and so forth.

I am using dini for files.

A huge thank you and a big +rep goes out to anyone who helps me with this! Thanks in advance!

- Jason
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)