14.06.2016, 00:21
So basically I'm trying to set up a unique groups system for my Roleplay server.
Now, there's one big issue with the system. Whenever a player uses /groupcreate when he tries it on the first time, it indeed creates a group in the MySQL Databases, however, In-game, the player is not hooked up with a group and it says he's not in a group when trying to use the features.
From the second attempt and furthur however, it hooks him up with the correct group.
Seems like the first try is bugged, and the rest are not.
Here are the code lines, I have tried so many options such as SetPVarInt however everything failed when a player firstly tries to do so:
+REPing the helpers !
Now, there's one big issue with the system. Whenever a player uses /groupcreate when he tries it on the first time, it indeed creates a group in the MySQL Databases, however, In-game, the player is not hooked up with a group and it says he's not in a group when trying to use the features.
From the second attempt and furthur however, it hooks him up with the correct group.
Seems like the first try is bugged, and the rest are not.
Here are the code lines, I have tried so many options such as SetPVarInt however everything failed when a player firstly tries to do so:
PHP Code:
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;
}
PHP Code:
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;
}
+REPing the helpers !