09.06.2012, 02:46
Well Guys I Fix One Problem And Another Emerges Hahhaha
Well when i execute the command it saves correctly but when ever i save when i have not changed it it saves as the id number of the group it is associated with.
Here Is The Stock For The Save
The Command That Works
Le Enum
And The Opening Query
My theory is i messed up the save some how but i don't see where i have
Well when i execute the command it saves correctly but when ever i save when i have not changed it it saves as the id number of the group it is associated with.
Here Is The Stock For The Save
pawn Код:
stock saveGroup(const id) {
if(strlen(groupVariables[id][gGroupName]) >= 1) {
format(szLargeString, sizeof(szLargeString), "UPDATE groups SET groupName = '%s', groupHQExteriorPosX = '%f', groupHQExteriorPosY = '%f', groupHQExteriorPosZ = '%f'", groupVariables[id][gGroupName], groupVariables[id][gGroupExteriorPos][0], groupVariables[id][gGroupExteriorPos][1], groupVariables[id][gGroupExteriorPos][2]);
format(szLargeString, sizeof(szLargeString), "%s, groupHQInteriorID = '%d', groupHQLockStatus = '%d', groupHQInteriorPosX = '%f', groupHQInteriorPosY = '%f', groupHQInteriorPosZ = '%f', groupSafeMoney = '%d', groupSafeMats = '%d', groupMOTD = '%s'", szLargeString, groupVariables[id][gGroupHQInteriorID],
groupVariables[id][gGroupHQLockStatus], groupVariables[id][gGroupInteriorPos][0], groupVariables[id][gGroupInteriorPos][1], groupVariables[id][gGroupInteriorPos][2], groupVariables[id][gSafe][0], groupVariables[id][gSafe][1], groupVariables[id][gGroupMOTD]);
format(szLargeString, sizeof(szLargeString), "%s, groupRankName1 = '%s', groupRankName2 = '%s', groupRankName3 = '%s', groupRankName4 = '%s', groupRankName5 = '%s', groupRankName6 = '%s'", szLargeString, groupVariables[id][gGroupRankName1], groupVariables[id][gGroupRankName2], groupVariables[id][gGroupRankName3], groupVariables[id][gGroupRankName4], groupVariables[id][gGroupRankName5], groupVariables[id][gGroupRankName6]);
format(szLargeString, sizeof(szLargeString), "%s, groupSafePosX = '%f', groupSafePosY = '%f', groupSafePosZ = '%f', MapIconID = '%d', groupType = '%d' WHERE groupID = '%d'", szLargeString, groupVariables[id][gSafePos][0], groupVariables[id][gSafePos][1], groupVariables[id][gSafePos][2],groupVariables[id][gMapIconID], groupVariables[id][gGroupType], id);
mysql_query(szLargeString);
}
else {
return 0;
}
return 1;
}
The Command That Works
pawn Код:
CMD:gmapicon(playerid, params[]) {
if(playerVariables[playerid][pAdminLevel] >= 4) {
new
groupID,
groupMapIcon;
if(sscanf(params, "dd", groupID, groupMapIcon))
return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/gmapicon [groupid] [mapiconid]");
if(groupID > 0 && groupID < MAX_GROUPS) {
format(szMessage, sizeof(szMessage), "You have set group %s's group type to %d.", groupVariables[groupID][gGroupName], groupMapIcon);
SendClientMessage(playerid, COLOR_WHITE, szMessage);
groupVariables[groupID][gMapIconID] = groupMapIcon;
} else return SendClientMessage(playerid, COLOR_GREY, "Invalid Group ID!");
}
return 1;
}
pawn Код:
enum groupE {
gGroupName[64],
gGroupType,
gMapIconID,
Float: gGroupExteriorPos[3],
Float: gGroupInteriorPos[3],
gGroupHQInteriorID,
gGroupPickupID,
Float: gSafePos[3],
gSafePickupID,
Text3D: gSafeLabelID,
Text3D: gGroupLabelID,
gGroupHQLockStatus,
gSafe[2], // 0-1: Money, mats. pot, cocaine out for now
gswatInv,
gGroupMOTD[128],
gGroupRankName1[32], // 4d arrays aren't supported in pawn, so I'll have to continue it like this...
gGroupRankName2[32],
gGroupRankName3[32],
gGroupRankName4[32],
gGroupRankName5[32],
gGroupRankName6[32],
}enum groupE {
gGroupName[64],
gGroupType,
gMapIconID,
Float: gGroupExteriorPos[3],
Float: gGroupInteriorPos[3],
gGroupHQInteriorID,
gGroupPickupID,
Float: gSafePos[3],
gSafePickupID,
Text3D: gSafeLabelID,
Text3D: gGroupLabelID,
gGroupHQLockStatus,
gSafe[2], // 0-1: Money, mats. pot, cocaine out for now
gswatInv,
gGroupMOTD[128],
gGroupRankName1[32], // 4d arrays aren't supported in pawn, so I'll have to continue it like this...
gGroupRankName2[32],
gGroupRankName3[32],
gGroupRankName4[32],
gGroupRankName5[32],
gGroupRankName6[32],
}
pawn Код:
case THREAD_INITIATE_GROUPS: {
mysql_store_result();
new
x;
while(mysql_retrieve_row()) {
mysql_get_field("groupID", result);
x = strval(result);
mysql_get_field("groupName", groupVariables[x][gGroupName]);
mysql_get_field("groupType", result);
groupVariables[x][gGroupType] = strval(result);
mysql_get_field("MapIconID", result);
groupVariables[x][gMapIconID] = strval(result);
mysql_get_field("groupHQExteriorPosX", result);
groupVariables[x][gGroupExteriorPos][0] = floatstr(result);
mysql_get_field("groupHQExteriorPosY", result);
groupVariables[x][gGroupExteriorPos][1] = floatstr(result);
mysql_get_field("groupHQExteriorPosZ", result);
groupVariables[x][gGroupExteriorPos][2] = floatstr(result);
mysql_get_field("groupHQInteriorPosX", result);
groupVariables[x][gGroupInteriorPos][0] = floatstr(result);
mysql_get_field("groupHQInteriorPosY", result);
groupVariables[x][gGroupInteriorPos][1] = floatstr(result);
mysql_get_field("groupHQInteriorPosZ", result);
groupVariables[x][gGroupInteriorPos][2] = floatstr(result);
mysql_get_field("groupHQInteriorID", result);
groupVariables[x][gGroupHQInteriorID] = strval(result);
mysql_get_field("groupHQLockStatus", result);
groupVariables[x][gGroupHQLockStatus] = strval(result);
mysql_get_field("groupSafeMoney", result);
groupVariables[x][gSafe][0] = strval(result);
mysql_get_field("groupSafeMats", result);
groupVariables[x][gSafe][1] = strval(result);
mysql_get_field("groupSafePosX", result);
groupVariables[x][gSafePos][0] = floatstr(result);
mysql_get_field("groupSafePosY", result);
groupVariables[x][gSafePos][1] = floatstr(result);
mysql_get_field("groupSafePosZ", result);
groupVariables[x][gSafePos][2] = floatstr(result);
/* mysql_get_field("groupSafePot", result);
groupVariables[x][gSafe][2] = strval(result);
mysql_get_field("groupSafeCocaine", result);
groupVariables[x][gSafe][3] = strval(result); Drugs are out for now. */
mysql_get_field("groupMOTD", groupVariables[x][gGroupMOTD]);
mysql_get_field("groupRankName1", groupVariables[x][gGroupRankName1]);
mysql_get_field("groupRankName2", groupVariables[x][gGroupRankName2]);
mysql_get_field("groupRankName3", groupVariables[x][gGroupRankName3]);
mysql_get_field("groupRankName4", groupVariables[x][gGroupRankName4]);
mysql_get_field("groupRankName5", groupVariables[x][gGroupRankName5]);
mysql_get_field("groupRankName6", groupVariables[x][gGroupRankName6]);
switch(groupVariables[x][gGroupHQLockStatus]) {
case 0: format(result, sizeof(result), "%s's HQ\n\nPress ~k~~PED_DUCK~ to enter.", groupVariables[x][gGroupName]);
case 1: format(result, sizeof(result), "%s's HQ\n\n(locked)", groupVariables[x][gGroupName]);
}
groupVariables[x][gGroupPickupID] = CreateDynamicPickup(1239, 23, groupVariables[x][gGroupExteriorPos][0], groupVariables[x][gGroupExteriorPos][1], groupVariables[x][gGroupExteriorPos][2], 0, -1, -1, 10);
groupVariables[x][gGroupLabelID] = CreateDynamic3DTextLabel(result, COLOR_YELLOW, groupVariables[x][gGroupExteriorPos][0], groupVariables[x][gGroupExteriorPos][1], groupVariables[x][gGroupExteriorPos][2], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 25.0);
groupVariables[x][gMapIconID] = CreateDynamicMapIcon(groupVariables[x][gGroupExteriorPos][0], groupVariables[x][gGroupExteriorPos][1], groupVariables[x][gGroupExteriorPos][2],groupVariables[x][gMapIconID], 1, -1, -1, -1, 100.0);
format(result, sizeof(result), "%s\nGroup Safe", groupVariables[x][gGroupName]);
groupVariables[x][gSafePickupID] = CreateDynamicPickup(1239, 23, groupVariables[x][gSafePos][0], groupVariables[x][gSafePos][1], groupVariables[x][gSafePos][2], GROUP_VIRTUAL_WORLD+x, groupVariables[x][gGroupHQInteriorID], -1, 10);
groupVariables[x][gSafeLabelID] = CreateDynamic3DTextLabel(result, COLOR_YELLOW, groupVariables[x][gSafePos][0], groupVariables[x][gSafePos][1], groupVariables[x][gSafePos][2], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, GROUP_VIRTUAL_WORLD+x, groupVariables[x][gGroupHQInteriorID], -1, 20.0);
}
mysql_free_result();
}