Group System - something's wrong -
LazzyBoy - 20.10.2017
Okay so first i was i/a on scripting for a while and now i came back so basicly i dont really have any idea where i left my things , i started testing group system ingame and i found something wrong with it , heres the thing.
If i create 2 groups for example
G 1 named Leos Group - first logged acc
G 2 named Lazys Group - second logged acc
While im still ingame it works but once i quit with both accounts and then login with second acc i get the infos of group 1 , and if i login with first acc i get second's group info
Can you please help me , let me know which code part do you need so i can bring them up.
Also the saving system is MYSQL
Table are
1- ID / 2- GroupName / 3 - GroupLeader which saves the ID/name and the owner.
Re: Group System - something's wrong -
Prokill911 - 20.10.2017
You're asking which code part but you haven't provided your code, so how do you expect someone to see an issue without having the code?
Re: Group System - something's wrong -
NaS - 20.10.2017
You should post the code for when the group is created (command I guess), how it's saved and of course how it is loaded.
Re: Group System - something's wrong -
LazzyBoy - 20.10.2017
Create group cmd
Код:
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;
}
Create group stock
Код:
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;
}
And heres the load one
Код:
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;
}
}
}
Re: Group System - something's wrong -
LazzyBoy - 21.10.2017
please help me i really need this
Re: Group System - something's wrong -
Sew_Sumi - 21.10.2017
OnPlayerDisconnect doesn't have code to make the 'groups' for that ID, removed?
This is more a common rookie mistake, as everything, upon disconnection, should be set to invalid IDs so this doesn't happen.
Case in point, is when you have an admin system, if there's a disconnection it HAS to be cleared, or the next person to connect will have admin status.
Re: Group System - something's wrong -
LazzyBoy - 21.10.2017
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
Re: Group System - something's wrong -
Sew_Sumi - 22.10.2017
Quote:
Originally Posted by LazzyBoy
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;
That line is causing -1 to be the new group tag...
You really need to be looking at this code more.
Re: Group System - something's wrong -
LazzyBoy - 22.10.2017
I dont think that PlayerInfo[playerid][pGroup] = groupid is the problem as long as the Player's group in player db is saved and loaded correctly , which means its GroupInfo[playerid][GroupID] but i have found another way around.
Код:
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
but i dont know if this would cause and problem while there will be more groups like 15/30 cuz i've tested it and doesnt really get mixed.
Anw Reppd + for the help.