22.04.2018, 10:56
When player uses /makefaction [name][type]
GetAvailableFactionID(); from stock above
and returnlastkey
I need this to be converted to BlueG's Mysql plugin 40+
PHP код:
stock CreateFaction(fname[], Float:PlayerPosX, Float:PlayerPosY, Float:PlayerPosZ, ftype)
{
DB::CreateRow(FactionTable, "FactionName", fname);
new year, month, day;
getdate(year, month, day);
new fcID = GetAvailableFactionID();
FactionInfo[fcID][dbID] = ReturnLastKey();
FactionInfo[fcID][fID] = fcID;
FactionInfo[fcID][fType] = ftype;
FactionInfo[fcID][fX] = PlayerPosX;
FactionInfo[fcID][fY] = PlayerPosY;
FactionInfo[fcID][fZ] = PlayerPosZ;
new cdate[30];
format(cdate, sizeof cdate, "%02d/%02d/%d", day, month, year);
DB::SetLastIntEntry(FactionTable, "fType", ftype, "Reference");
DB::SetLastFloatEntry(FactionTable, "LockerX", PlayerPosX, "Reference");
DB::SetLastFloatEntry(FactionTable, "LockerY", PlayerPosY, "Reference");
DB::SetLastFloatEntry(FactionTable, "LockerZ", PlayerPosZ, "Reference");
DB::SetLastStringEntry(FactionTable, "CreationDate", cdate, "Reference");
LoadFactions();
#if defined DEBUG_MODE
printf("[FACTION CREATION] %s has been created today (%s). [IG ID: %d | SQL ID: %d]", fname, cdate, fcID, FactionInfo[fcID][dbID]);
#endif
return 1;
}
PHP код:
stock GetAvailableFactionID()
{
new id;
for(new i; i < MAX_FACTIONS; i++)
{
if(FactionInfo[i][dbID] == 0)
{
id = i;
break;
}
}
return id;
}
PHP код:
stock ReturnLastKey()
{
return DB::GetRowsPoolSize(FactionTable);
}