COMMAND:groupcreate(playerid, params[])
{
if(PlayerInfo[playerid][pGroup] != 0) return SendClientError(playerid, "You are already in a group!");
new iChoice[40];
if(sscanf(params, "s[40]", iChoice)) return SCP(playerid, "[Group-Name]");
if(200000 > HandMoney(playerid)) return SendClientError(playerid, "You need atleast $200,000 in hand to create group");
GivePlayerMoneyEx(playerid,-200000);
CreateGroup(iChoice, playerid);
return 1;
}
stock CreateGroup(groupName[], playerid)
{
new groupid = GetUnusedGroup();
if(groupid == -1) return printf("[ERROR] - Maximum Groups reached. %d/%d", groupid, MAX_GROUPS);
new iFormat[128], iQuery[260];
format(iFormat, sizeof(iFormat), "%s has created a new group(%s).", PlayerName(playerid), groupName);
SetPVarInt(playerid, "GroupID", groupid);
PlayerInfo[playerid][pGroup] = groupid;
mysql_format(MySQLPipeline, iQuery, sizeof(iQuery), "INSERT INTO `groupinfo` (`ID`, `GroupName`, `Leader`) VALUES (%d, '%e', '%e')", groupid, groupName, PlayerName(playerid));
mysql_tquery(MySQLPipeline, iQuery);
ReloadGroup(groupid, false);
return 1;
}
stock GetUnusedGroup()
{
GroupLoop(g)
{
if(GroupInfo[g][gActive] != true) return g;
}
return -1;
}
enum g_Info
{
gName[MAX_FACTION_NAME],
gLeader[MAX_PLAYER_NAME],
bool:gActive,
}
new GroupInfo[MAX_GROUPS][g_Info];
Try printing groupid and then restart your server and use it again. Show me what it outputs
|