COMMAND:creategroup(playerid, params[])
{
if(PlayerInfo[playerid][pGroup] != -1) return SendClientError(playerid,"You are already in a group");
new name[128];
if(sscanf(params, "s", name)) return SCP(playerid,"creategroup[ Name]");
{
new groupid = GetUnusedGroup();
if(groupid == -1) return SendClientError(playerid,"The maximum has been reached,you cannot create more groups!!");
CreateGroup(name,RPName(playerid));
PlayerInfo[playerid][pGroup] = groupid;
ReloadGroup(groupid,true);
new iQuery[250];
mysql_format(MySQLPipeline, iQuery, sizeof(iQuery), "UPDATE `GROUPINFO` SET `ID` = %d WHERE `GroupLeader` = '%e'",PlayerInfo[playerid][pGroup],RPName(playerid));
mysql_tquery(MySQLPipeline, iQuery);
//SaveAccount(playerid);
printf("%d",PlayerInfo[playerid][pGroup]);
}
return 1;
}
stock CreateGroup(GroupNames[],GroupLeaders[])
{
new Groupid = GetUnusedGroup();
if(Groupid == -1) return printf("[ERROR] - Maximum GroupS reached. %d/%d", Groupid, MAX_GroupS);
new iQuery[250];
mysql_format(MySQLPipeline, iQuery, sizeof(iQuery), "INSERT INTO `GroupInfo` (`ID`, `GroupName`,`GroupLeader`) VALUES (%d,'%e','%e')",Groupid,GroupNames,GroupLeaders);
mysql_tquery(MySQLPipeline, iQuery);
ReloadGroup(Groupid, false);
return 1;
}
function:OnLoadGroupS(fromstart)
{
if(fromstart == 1)
{
GroupLoop(i)
{
GroupInfo[i][GroupActive] = false;
}
}
new fields, rows;
cache_get_data(rows, fields, MySQLPipeline);
if(rows)
{
for(new row; row < rows; row++)
{
new iGet[128];
cache_get_field_content(row, "ID", iGet, MySQLPipeline); new Groupid = strval(iGet);
cache_get_field_content(row, "GroupName", iGet, MySQLPipeline); myStrcpy(GroupInfo[Groupid][GroupName], iGet);
cache_get_field_content(row, "GroupLeader", iGet, MySQLPipeline); myStrcpy(GroupInfo[Groupid][GroupLeader], iGet);
GroupInfo[Groupid][GroupActive] = true;
}
}
}
|
I have set the Playerinfo groupid to -1 while he quits at OnPlayerDisconnect but not GroupInfo[playerid][GroupID](cuz it doesnt really do anything) Now if i set GroupID to -1 and create new group it stays -1 all the time even when i quit , i dont really see where's the problem right now, i've debugged the /g showing the ID of PlayerInfo[playerid][pGroup] and its same with the DB's one but GroupInfo[playerid][groupID] its not its either 0 or -1
|
PlayerInfo[playerid][pGroup] = groupid;
new group = PlayerInfo[playerid][pGroup] GroupInfo[group][GroupName] // in this way i was able to get the real id of group and everything else correctly