26.01.2014, 08:58
Hello, I am kinda new to MySQL and I was wondering if you guys could help me out.
CMD:
Saving:
How it's displaying on phpmyadmin:

And I got another question, I am making a /factions command where you can see both the offline and online members of a faction but when I select online I just see my name and when I invite another player you will only be able to see his name and for offline it isn't displaying the dialog.
Dialog on /factions:
CMD:
PHP код:
CMD:createatm(playerid, params[])
{
if (IsPlayerAdminLevel(playerid, 4))
{
new string[64];
new objectid = -1;
for (new i = 0; i < MAX_DYNAMIC_ATMS; i ++)
{
if (!ATMEnum[i][objectExists])
{
objectid = i;
break;
}
}
if (objectid != -1)
{
format(string, sizeof(string), "INSERT INTO `ATMs` (`objectID`) VALUES('%d')", objectid);
mysql_query(string);
new Float:x, Float:y, Float:z, Float:angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
ATMEnum[objectid][objectExists] = true;
ATMEnum[objectid][objectModel] = 2618;
ATMEnum[objectid][objectX] = x + (1.4 * floatsin(-angle, degrees));
ATMEnum[objectid][objectY] = y + (1.4 * floatcos(angle, degrees));
ATMEnum[objectid][objectZ] = z;
ATMEnum[objectid][objectRotX] = 0.0;
ATMEnum[objectid][objectRotY] = 0.0;
ATMEnum[objectid][objectRotZ] = angle;
ATMEnum[objectid][objectInterior] = GetPlayerInterior(playerid);
ATMEnum[objectid][objectVirtual] = GetPlayerVirtualWorld(playerid);
ATMEnum[objectid][objectID] = CreateDynamicObject(ATMEnum[objectid][objectModel], ATMEnum[objectid][objectX], ATMEnum[objectid][objectY], ATMEnum[objectid][objectZ], 0.0, 0.0, ATMEnum[objectid][objectRotZ], ATMEnum[objectid][objectVirtual], ATMEnum[objectid][objectInterior]);
format(string, sizeof(string), "Type {FFFFFF}/atm{F5DEB3} to use this atm.");
ATMEnum[objectid][objectLabel] = CreateStreamed3DTextLabel(string, YELLOW2, ATMEnum[objectid][objectX], ATMEnum[objectid][objectY], ATMEnum[objectid][objectZ]+1.5, 15.0, ATMEnum[objectid][objectVirtual]);
ATMEnum[objectid][atmICON] = CreateDynamicMapIcon(ATMEnum[objectid][objectY], ATMEnum[objectid][objectY], ATMEnum[objectid][objectY], 52, 0);
DestroyDynamicMapIcon(ATMEnum[objectid][atmICON]);
SaveATM(objectid);
format(string, sizeof(string), "You have created an ATM (%d).", objectid);
SendClientMessage(playerid, WHITE, string);
return 1;
}
else return ErrorMessage(playerid, "You cannot create anymore objects.");
}
else ErrorMessage(playerid, "You are not authorized to use this command.");
return 1;
}
PHP код:
stock SaveATM(objectid)
{
if (objectid >= 0 && objectid < MAX_DYNAMIC_ATMS)
{
if (ATMEnum[objectid][objectExists])
{
new query[768];
format(query, sizeof(query), "UPDATE `ATMs` SET `objectModel` = '%d', `objectX` = '%.4f', `objectY` = '%.4f', `objectZ` = '%.4f', `objectRotX` = '%.4f', `objectRotY` = '%.4f', `objectRotZ` = '%.4f', `objectInterior` = '%d', `objectVirtual` = '%d' WHERE `objectID` = '%d'",
ATMEnum[objectid][objectModel],
ATMEnum[objectid][objectX],
ATMEnum[objectid][objectY],
ATMEnum[objectid][objectZ],
ATMEnum[objectid][objectRotX],
ATMEnum[objectid][objectRotY],
ATMEnum[objectid][objectRotZ],
ATMEnum[objectid][objectInterior],
ATMEnum[objectid][objectVirtual],
objectid
);
mysql_query(query);
}
}
return 1;
}

And I got another question, I am making a /factions command where you can see both the offline and online members of a faction but when I select online I just see my name and when I invite another player you will only be able to see his name and for offline it isn't displaying the dialog.
Dialog on /factions:
PHP код:
case DIALOG_FACTIONS:
{
if (response)
{
if (!FactionEnum[listitem + 1][factionExists])
{
ErrorMessage(playerid, "That faction isn't taken yet.");
return 1;
}
else
{
if (FactionEnum[listitem + 1][factionType] == FACTION_HITMAN && PlayerEnum[playerid][pAdmin] < 3)
{
ErrorMessage(playerid, "This faction is classified.");
return 1;
}
SetPVarInt(playerid, "SelectFaction", listitem + 1);
ShowPlayerDialog(playerid, DIALOG_FACTIONS_INDEX, DIALOG_STYLE_LIST, "Factions", "Online Members\nOffline Members", "Select", "Close");
}
}
return 1;
}
PHP код:
case DIALOG_FACTIONS_INDEX:
{
if (response)
{
switch (listitem)
{
case 0:
{
foreach (Player, i)
{
if (IsPlayerConnected(i))
{
new title[32], string2[520];
if(PlayerEnum[i][pFaction] == GetPVarInt(playerid, "SelectFaction"))
{
format(string2, sizeof(string2), "%s%s (Rank: %d)\n", string2, PlayerName(i, false), PlayerEnum[i][pFactionRank]);
}
format(title, sizeof(title), "%s", FactionEnum[listitem + 1][factionName]);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, title, string2, "Close", "");
}
}
}
case 1:
{
new
result[2][32],
string2[500], title[32];
mysql_query("SELECT `Username`, `FactionRank` FROM `Accounts` Where `Faction` = '%d' ORDER BY `FactionRank` DESC", GetPVarInt(playerid, "SelectFaction"));
mysql_store_result();
if (mysql_num_rows() < 1) return 0;
while (mysql_retrieve_row())
{
mysql_fetch_field_row(result[0], "Username");
mysql_fetch_field_row(result[1], "FactionRank");
format(string2, sizeof(string2), "%s%s (Rank: %d)\n",string2, result[0], strval(result[1]));
}
format(title, sizeof(title), "%s", FactionEnum[listitem + 1][factionName]);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, title, string2, "Close", "");
}
}
}
}