23.02.2016, 21:22
Hi. I've been trying to get my /createfaction command to work all day long but I haven't been able to name the .ini file to the number I type in game.
No matter what I type in game, it would always create a file named "0.ini". I've tried using strval() but I ended up getting 65535.ini and etc.
What I want to do is type /createfaction 1 and a file named 1.ini to appear in my factions folder.
I read a lot of topics with similar but not exactly this problem, most of them were using dini not yini like I am. None of them fixed it for me.
Thanks for anyone who helps.
No matter what I type in game, it would always create a file named "0.ini". I've tried using strval() but I ended up getting 65535.ini and etc.
What I want to do is type /createfaction 1 and a file named 1.ini to appear in my factions folder.
Код:
CMD:createfaction(playerid,params[]){ if(PlayerInfo[playerid][pAdmin] >= 4){ new fid[2]; new string[128]; if(sscanf(params, "u", strval(fid))) return SendClientMessage(playerid, -1, "USAGE: /createfaction [Faction-Slot]"); if(strval(fid) <=0 || strval(fid) >=16) return SendClientMessage(playerid, -1, "Invalid Faction ID. ( 1-15 )"); new Factionfile[32]; format(Factionfile, sizeof(Factionfile), "factions/%d.ini", strval(fid)); new INI:File = INI_Open(Factionfile); INI_SetTag(File,"data"); INI_WriteString(File,"Faction Name","Default"); INI_WriteInt(File,"Faction Type",0); INI_WriteInt(File,"Total Members",0); INI_WriteString(File,"Rank 1","Default"); INI_WriteString(File,"Rank 2","Default"); INI_WriteString(File,"Rank 3","Default"); INI_WriteString(File,"Rank 4","Default"); INI_WriteString(File,"Rank 5","Default"); INI_WriteString(File,"Rank 6","Default"); INI_WriteString(File,"Rank 7","Default"); INI_WriteString(File,"Rank 8","Default"); INI_WriteString(File,"Rank 9","Default"); INI_WriteString(File,"Rank 10","Default"); INI_Close(File); format(string, sizeof(string), "You created a faction at slot %d.", strval(fid)); return SendClientMessage(playerid, 0xffffffff, string); } return 1; }
Thanks for anyone who helps.