Skip to content

Instantly share code, notes, and snippets.

@plenarius
Created January 30, 2019 00:11
Show Gist options
  • Save plenarius/75c6e4cfc70629fcf4f03f6490733b3f to your computer and use it in GitHub Desktop.
Save plenarius/75c6e4cfc70629fcf4f03f6490733b3f to your computer and use it in GitHub Desktop.
void SyncPins(object oPC, int iFeedback=0)
{
int iPins = GetLocalInt(oPC, "NW_TOTAL_MAP_PINS");
if (iPins == 0)
return;
int iIter = 1;
int iCount = 1;
string sPCID = IntToString(GetPlayerID(oPC));
string sSQL = "DELETE FROM player_maps WHERE player_id = "+sPCID;
SQLExecDirect(sSQL);
sSQL = "INSERT INTO player_maps VALUES ";
while (iIter <= iPins)
{
string sIter = IntToString(iIter);
object oArea = GetLocalObject(oPC, "NW_MAP_PIN_AREA_" + sIter);
if (oArea == OBJECT_INVALID)
{
iIter++;
continue;
}
string sEncDesc = SQLEncodeSpecialChars(GetLocalString(oPC, "NW_MAP_PIN_NTRY_" + sIter));
float fX = GetLocalFloat(oPC, "NW_MAP_PIN_XPOS_" + sIter);
float fY = GetLocalFloat(oPC, "NW_MAP_PIN_YPOS_" + sIter);
string sAreaID = IntToString(GetAreaID(oArea));
string sCount = IntToString(iCount);
sSQL += "("+sCount+","+sPCID+","+sAreaID+","+FloatToString(fX)+","+FloatToString(fY)+",'"+sEncDesc+"'),";
iCount++;
iIter++;
}
sSQL = GetSubString(sSQL,0,GetStringLength(sSQL)-1);
if (iCount > 1)
SQLExecDirect(sSQL);
if (iFeedback)
SendMessageToPC(oPC, LOE_COLOUR_WHEAT+"Map pins have been saved.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment