![]() |
|
[Pawn] cache_insert_id always return 0 - Printable Version +- open.mp forum (https://forum.open.mp) +-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) +--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) +--- Thread: [Pawn] cache_insert_id always return 0 (/showthread.php?tid=2282) |
cache_insert_id always return 0 - Axitz - 2022-03-30 Hi, sorry how bad this was. I've created a team and the table is also is AI mode. There are multiples team in the query but whenever server restart or player quit, then create team, it always started at 0 again. PHP Code: forward TeamCreated(b);
public TeamCreated(b)
{
? ? TeamInfo[b][TeamID] = cache_insert_id();
? ? teamidd;
? ? printf("New Group is created: [%d]", teamidd );
}
PHP Code: if(strcmp(usage, "create", false) == 0)
{
? ? if(!strlen(usage1)) return SCP(playerid, "create <teamname>");
? ? if(strlen(usage1) < 5 || strlen(usage1) > 30) return SendClientError(playerid, "Your team name is too short or too long! (Min 5, Max 30 chars)");
? ? new tmID = teamidd;
? ? if(PlayerInfo[playerid][tplayerteam] != -1) return SendClientError(playerid, "You are already in a team. /team leave");
? ? TeamInfo[tmID][TeamID] = tmID;
? ? PlayerInfo[playerid][tplayerteam] = tmID;
? ? PlayerInfo[playerid][tranklvl] = 0;
? ? myStrcpy(PlayerInfo[playerid][TPTeamName],usage1);
? ? myStrcpy(PlayerInfo[playerid][trankname],"Children");
? ? TeamInfo[tmID][TActive]=true;
new sQuery[528];
mysql_format(sqldb, sQuery, sizeof sQuery, "INSERT INTO `TeamInfo` (`TeamID`, `TeamName`, `StartRank`) VALUES (%d,'%e', 'Children')",tmID,usage1);
mysql_tquery(sqldb, sQuery, "TeamCreated", "i",tmID);
}
else
{
SCP(playerid, "<create> <input>");
}
return 1;
}
RE: cache_insert_id always return 0 - FARADAY - 2022-03-31 where are you upload GroupCreated? error mysql: `TeamName``StartRank` RE: cache_insert_id always return 0 - Axitz - 2022-04-01 Ops sorry, my bad it was TeamCreated not GroupCreated. Problem still occurs. RE: cache_insert_id always return 0 - FARADAY - 2022-04-01 Where are the groups loaded when the mod starts? Is there teamidd? RE: cache_insert_id always return 0 - Radical - 2022-04-01 (2022-03-30, 07:41 AM)Axitz Wrote: but whenever server restart or player quit, then create team, it always started at 0 again. This is due to a "teamidd" variable reset on exit. You should add? teamidd? where you load the teams. ------------------------------------------------------- Recommended: If you want to get a free team ID, use this function: Code: GetFreeTeamID() {
? ? for (new i; i < MAX_TEAMS; i) {
? ? ? ? if (TeamInfo[i][TActive] == false)
? ? ? ? ? ? return i;
? ? }
? ? return -1; //Return -1 when there is no free team ID
}Code: new tmID = GetFreeTeamID();
if (tmID == -1)
? ? return 1; //No free team ID
else
? ? TeamInfo[tmID][TActive] = true;RE: cache_insert_id always return 0 - Axitz - 2022-04-07 Sorry late, it doesn't seem to fix the issue as well. |