PlayerInfo saving/reading the array problem [+REP]
#1

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:
PHP Code:
COMMAND:groupcreate(playeridparams[])
{
    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(iChoiceplayerid);
    return 
1;

PHP Code:
stock CreateGroup(groupName[], playerid)
{
    new 
groupid GetUnusedGroup();
    if(
groupid == -1) return printf("[ERROR] - Maximum Groups reached. %d/%d"groupidMAX_GROUPS);
    new 
iFormat[128], iQuery[260];
    
format(iFormatsizeof(iFormat), "%s has created a new group(%s)."PlayerName(playerid), groupName);
    
SetPVarInt(playerid"GroupID"groupid);
    
PlayerInfo[playerid][pGroup] = groupid;
    
mysql_format(MySQLPipelineiQuerysizeof(iQuery), "INSERT INTO `groupinfo` (`ID`, `GroupName`, `Leader`) VALUES (%d, '%e', '%e')"groupidgroupNamePlayerName(playerid));
    
mysql_tquery(MySQLPipelineiQuery);
    
ReloadGroup(groupidfalse);
    return 
1;


+REPing the helpers !
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)