SA-MP Forums Archive
Help with making a faction - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with making a faction (/showthread.php?tid=208896)



Help with making a faction - command won't work - Outcast - 09.01.2011

I use zcmd and I try to make a command /setleader1 that would make a .ini file for SFPD in factions folder. I made it like I made PlayerInfo thing but for some reason the command wont execute and I get a message SERVER: Unknown command.

This is my code:
Код:
COMMAND:setleader1(playerid, params[])
	{
		new leaderid;
		new getname[30];
	   	if(sscanf(params, "i", leaderid)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setleader1 [playerID]");
        dini_Create(SERVER_FACTION_SFPD_FILE);
        dini_IntSet(SERVER_FACTION_SFPD_FILE, "Leaderl",FactionSFPD[playerid][fLeader] = GetPlayerName(leaderid, getname, 30));
		return 1;
	}
Please help me out a bit. Thanks


Re: Help with making a faction - JaTochNietDan - 09.01.2011

First of all, this makes more sense:

pawn Код:
GetPlayerName(leaderid, FactionSFPD[playerid][fLeader], 30)
dini_IntSet(SERVER_FACTION_SFPD_FILE, "Leaderl",FactionSFPD[playerid][fLeader]);
Which means there's no need for that wasteful allocation of memory that is new getname[30];

Next, are you sure you're defining fLeader as an array? Lets see the enum where you create it.


Re: Help with making a faction - Outcast - 09.01.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
First of all, this makes more sense:

pawn Код:
GetPlayerName(leaderid, FactionSFPD[playerid][fLeader], 30)
dini_IntSet(SERVER_FACTION_SFPD_FILE, "Leaderl",FactionSFPD[playerid][fLeader]);
Which means there's no need for that wasteful allocation of memory that is new getname[30];

Next, are you sure you're defining fLeader as an array? Lets see the enum where you create it.
Here it is:
Код:
enum fFactionSFPD
{
    fLeader[30],
    fFactionName,
    fRank1,
    fRank2,
    fRank3,
    fRank4,
    fRank5,
    fSkin1,
    fSkin2,
    fSkin3,
    fSkin4,
    fSkin5,
    fSkin6,
}



Re: Help with making a faction - JaTochNietDan - 09.01.2011

Okay, well have you tried the code I pasted?


Re: Help with making a faction - Outcast - 09.01.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Okay, well have you tried the code I pasted?
Yes but the command is not recognized. It says SERVER: Unknown command.


Re: Help with making a faction - JaTochNietDan - 09.01.2011

Well that must be something to do with your command processor then, and I don't use ZCMD so I wouldn't know what the issue is there.


Re: Help with making a faction - Outcast - 09.01.2011

Thanks anyway.

Anyone else has a suggestion to solve this?


Re: Help with making a faction - blackwave - 09.01.2011

You may forgot

pawn Код:
#include <zcmd>
Also I've tried once ZCMD, and got same thing as you: "Unknown command". Why dont you use strcmp + sscanf? Or even dcmd, which on this situation, doesn't needs sscanf


Re: Help with making a faction - Outcast - 09.01.2011

Quote:
Originally Posted by blackwave
Посмотреть сообщение
You may forgot

pawn Код:
#include <zcmd>
Also I've tried once ZCMD, and got same thing as you: "Unknown command". Why dont you use strcmp + sscanf? Or even dcmd, which on this situation, doesn't needs sscanf
All my other zcmd commands work. What's the difference between ZCMD and DCMD?


Re: Help with making a faction - Calgon - 09.01.2011

Paste the line of code where you declare your enum (the 'new' part).

Quote:
Originally Posted by blackwave
Посмотреть сообщение
You may forgot

pawn Код:
#include <zcmd>
Also I've tried once ZCMD, and got same thing as you: "Unknown command". Why dont you use strcmp + sscanf? Or even dcmd, which on this situation, doesn't needs sscanf
dcmd is less efficient than zcmd, why would you recommend a slower method when you haven't even examined the situation properly? zcmd is the most efficient way, and strcmp is the slowest. sscanf returns users by ids/names with the "u" parameter, which the OP should probably use.