• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] cache_insert_id always return 0
#1
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; }
  Reply
#2
where are you upload GroupCreated?



error mysql: `TeamName``StartRank`
  Reply
#3
Ops sorry, my bad it was TeamCreated not GroupCreated.



Problem still occurs.
  Reply
#4
Where are the groups loaded when the mod starts?
Is there teamidd?
  Reply
#5
(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;
  Reply
#6
Sorry late, it doesn't seem to fix the issue as well.
  Reply