In-Game House Creating System Help
#1

Essentially, im trying to just make a /makehouse command, so admins IG can make houses, so i dont ahve to do it myself typing shit in property.cfg

I have never worked with saving NEW strings in a scriptfile, and am encountering some problems.

here is the codes:

Code:
public MakeHouse()
{
    new File: file2;
 
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,0,0,0,0,0,0,The State,%s,%d,0,0,0,0,0,0,0,0,0,0,0,0,0,%d,%d\n",
        NewHouseX,
        NewHouseY,
        NewHouseZ,
        NewHIntX,
        NewHIntY,
        NewHIntZ,
        NewHDesc,
        NewHCost,
        NewHSkin,
        NewHLevel,
        NewHWorld);
        file2 = fopen("property.cfg", io_write);
        fwrite(file2, coordsstring);
        fclose(file2);
}
Code:
if(strcmp(cmd, "/makehouse", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
       if (PlayerInfo[playerid][pAdmin] >= 5)
            {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new enterx;
            tmp = strtok(cmdtext, idx);
            enterx = strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new entery;
            tmp = strtok(cmdtext, idx);
            entery = strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new enterz;
            tmp = strtok(cmdtext, idx);
            entery = strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new hdesc;
            tmp = strtok(cmdtext, idx);
            hdesc = strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new hprice;
            tmp = strtok(cmdtext, idx);
            hprice = strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new hintid;
            tmp = strtok(cmdtext, idx);
            hintid = strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new hlevel;
            tmp = strtok(cmdtext, idx);
            hlevel = strval(tmp);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /makehouse [ExitX] [ExitY] [ExitZ] [Desc] [Price] [IntID] [Level] [VW]");
                return 1;
            }
            new hvw;
            tmp = strtok(cmdtext, idx);
            hvw = strval(tmp);
 
                new Float:x, Float:y, Float:z;
            GetPlayerPos(playerid,x,y,z);
                NewHouseX = x;
                NewHouseY = y;
                NewHouseZ = z;
                NewHIntX = enterx;
                NewHIntY = entery;
                NewHIntZ = enterz;
                NewHDesc = hdesc;
                NewHCost = hprice;
                NewHSkin = hintid;
                NewHLevel = hlevel;
                NewHWorld = hvw;
                MakeHouse();
                OnPropUpdate();
                LoadProperty();
                CustomPickups();
                SendClientMessage(playerid, COLOR_GRAD2, "House Created!");
                }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");
            }
        }
        return 1;
    }
I personally believe it has something to do with public MakeHouse() IT all compiles fine, the /makehouse command SEEMS to work, ends up printing "House Created!", but nothing happens.

If you could helpp, that'd be great. Thanks.
Reply
#2

No one knows whats wrong?
Reply
#3

Try

pawn Code:
public MakeHouse(NewHouseX, NewHouseY, NewHouseZ, NewHIntX, NewHIntY, NewHIntZ, NewHDesc, NewHCost, NewHSkin, NewHLevel, NewHWorld)
{
    new File: file2;
 
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,0,0,0,0,0,0,The State,%s,%d,0,0,0,0,0,0,0,0,0,0,0,0,0,%d,%d\n",
        NewHouseX,
        NewHouseY,
        NewHouseZ,
        NewHIntX,
        NewHIntY,
        NewHIntZ,
        NewHDesc,
        NewHCost,
        NewHSkin,
        NewHLevel,
        NewHWorld);
        file2 = fopen("property.cfg", io_write);
        fwrite(file2, coordsstring);
        fclose(file2);
}
Change:
pawn Code:
MakeHouse();
to
pawn Code:
MakeHouse(NewHouseX, NewHouseY, NewHouseZ, NewHIntX, NewHIntY, NewHIntZ, NewHDesc, NewHCost, NewHSkin, NewHLevel, NewHWorld);
Reply
#4

Yo u should post it as a FS that will be nice men
Reply
#5

Quote:
Originally Posted by Trill
but nothing happens.
Does the file get created ? Also, debug coordstring so you see it if has any info, before writing to the file
Reply
#6

Quote:

C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHouseX" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHouseY" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHouseZ" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHIntX" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHIntY" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHIntZ" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHDesc" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHCost" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHSkin" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHLevel" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(2392) : warning 219: local variable "NewHWorld" shadows a variable at a preceding level
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(970 : warning 202: number of arguments does not match definition
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(12527) : warning 202: number of arguments does not match definition
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(26532) : warning 213: tag mismatch
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(26533) : warning 213: tag mismatch
C:\Users\family\Downloads\sampserver\sampserver\ga memodes\el-rp.pwn(26534) : warning 213: tag mismatch

It compiles like that, when making those edits. And still doesnt work. I thank you for your help, any other suggestions anyone?
Reply
#7

Quote:
Originally Posted by dice7
Quote:
Originally Posted by Trill
but nothing happens.
Does the file get created ? Also, debug coordstring so you see it if has any info, before writing to the file
i was going to, i havent scripted in a few months, and forget the thing to add at the end of the line to debug. mind jogging my memory?
Reply
#8

Sorry for double post, but can anyone help?
Reply
#9

no one else can help?
Reply
#10

Does something get saved to property.cfg?

and io_write will overwrite what you already have in the file.. i think you should use io_append
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)