enums and database saving -
bosmania - 25.02.2019
i just started working on a clan system and i hit a bump in the road
i just tried to get a clan to create in the database and i did this and i am getting the error
error 017: undefined symbol "clanid".i know what it means,where i define this,i tried to use this the same way i use playerid.
it would mean a lot if u would help me and not send me on some site.
#define MAX_CLANS (100)
enum cInfo{
cID,
cName[MAX_CLAN_NAME]
}
new ClanInfo[MAX_CLANS][cInfo];
#define cNamex 48
function UpdateClanVariable(clanid, varid)
{
new query[256];
switch(varid){
case cNamex: format(query, sizeof(query), "UPDATE `clans` SET `ClanName`='%s' WHERE `ID`='%d'", ClanInfo[clanid][cName], ClanInfo[clanid][cID]);
}
mysql_tquery(mysql, query, "", "");
return 1;
}
ClanInfo[clanid][cName] = cache_get_field_content_int(0, "ClanName", mysql);
Re: enums and database saving -
feartonyb - 26.02.2019
Paste function where this line is
Quote:
ClanInfo[clanid][cName] = cache_get_field_content_int(0, "ClanName", mysql);
|
Also, you don't have to use empty space args in mysql_tquery. You can simply use mysql_tquery(mysql, query);
And you should probably define function UpdateClanVariable as stock, not function.
Re: enums and database saving -
bosmania - 26.02.2019
So,how do i make a clan to get saved in the database when a player creates it form the premium shop?
Re: enums and database saving -
bosmania - 26.02.2019
case DIALOG_LOGIN: {
if(!response) return Kick(playerid);
mysql_format(mysql, szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `Username` = '%s' AND `Password` = '%e' LIMIT 1;", GetName(playerid), inputtext);
mysql_query(mysql, szQuery);
szQuery[0] = EOS;
WarningAttemps[playerid] += 1;
if(!cache_get_row_count(mysql)) {
if(PlayerInfo[playerid][pLanguage] <= 1) {
format(szQuery, sizeof(szQuery), "Bine ai revenit, %s.\nIntrodu parola pentru a te autentifica pe contul tau. {FF0606}[%d/3]", GetName(playerid), WarningAttemps[playerid]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", szQuery, "Select", "Iesire");
}
else if(PlayerInfo[playerid][pLanguage] == 2) {
format(szQuery, sizeof(szQuery), "Welcome, %s.\nInsert your password to login to your account. {FF0606}[%d/3]", GetName(playerid), WarningAttemps[playerid]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login", szQuery, "Select", "Quit");
}
if(WarningAttemps[playerid] >= 3) { Kick(playerid); }
return 1;
}
TogglePlayerSpectating(playerid, 0);
new sz[256];
PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID", mysql);
cache_get_field_content(0, "Username", sz); format(PlayerInfo[playerid][pUsername], 256, sz);
PlayerInfo[playerid][pLevel] = cache_get_field_content_int(0, "Level", mysql);
PlayerInfo[playerid][pRespect] = cache_get_field_content_int(0, "Respect", mysql);
PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin", mysql);
PlayerInfo[playerid][pHelper] = cache_get_field_content_int(0, "Helper", mysql);
PlayerInfo[playerid][pMoney] = cache_get_field_content_int(0, "Money", mysql);
PlayerInfo[playerid][pBankMoney] = cache_get_field_content_int(0, "BankMoney", mysql);
PlayerInfo[playerid][pHouseKey] = cache_get_field_content_int(0, "HouseKey", mysql);
PlayerInfo[playerid][pBusinessKey] = cache_get_field_content_int(0, "BusinessKey", mysql);
PlayerInfo[playerid][pRentedHouse] = cache_get_field_content_int(0, "RentedHouse", mysql);
PlayerInfo[playerid][pFaction] = cache_get_field_content_int(0, "Faction", mysql);
PlayerInfo[playerid][pMember] = cache_get_field_content_int(0, "Member", mysql);
PlayerInfo[playerid][pLeader] = cache_get_field_content_int(0, "Leader", mysql);
PlayerInfo[playerid][pRank] = cache_get_field_content_int(0, "Rank", mysql);
PlayerInfo[playerid][pFactionPunish] = cache_get_field_content_int(0, "FactionPunish", mysql);
PlayerInfo[playerid][pSex] = cache_get_field_content_int(0, "Sex", mysql);
PlayerInfo[playerid][pAge] = cache_get_field_content_int(0, "Age", mysql);
PlayerInfo[playerid][pMuted] = cache_get_field_content_int(0, "Muted", mysql);
PlayerInfo[playerid][pMuteTime] = cache_get_field_content_int(0, "MuteTime", mysql);
PlayerInfo[playerid][pJailed] = cache_get_field_content_int(0, "Jailed", mysql);
PlayerInfo[playerid][pJailTime] = cache_get_field_content_int(0, "JailTime", mysql);
PlayerInfo[playerid][pWantedLevel] = cache_get_field_content_int(0, "WantedLevel", mysql);
cache_get_field_content(0, "WantedReason", sz); format(PlayerInfo[playerid][pWantedReason], 256, sz);
PlayerInfo[playerid][pWantedTime] = cache_get_field_content_int(0, "WantedTime", mysql);
cache_get_field_content(0, "Email", sz); format(PlayerInfo[playerid][pEmail], 256, sz);
PlayerInfo[playerid][pSkin] = cache_get_field_content_int(0, "Skin", mysql);
PlayerInfo[playerid][pContract] = cache_get_field_content_int(0, "Contract", mysql);
PlayerInfo[playerid][pContractValue] = cache_get_field_content_int(0, "ContractValue", mysql);
PlayerInfo[playerid][pLanguage] = cache_get_field_content_int(0, "Language", mysql);
PlayerInfo[playerid][pBanned] = cache_get_field_content_int(0, "Banned", mysql);
PlayerInfo[playerid][pCarLicence] = cache_get_field_content_int(0, "CarLicence", mysql);
PlayerInfo[playerid][pFlyLicence] = cache_get_field_content_int(0, "FlyLicence", mysql);
PlayerInfo[playerid][pBoatLicence] = cache_get_field_content_int(0, "BoatLicence", mysql);
PlayerInfo[playerid][pBikeLicence] = cache_get_field_content_int(0, "BikeLicence", mysql);
PlayerInfo[playerid][pGunLicence] = cache_get_field_content_int(0, "GunLicence", mysql);
PlayerInfo[playerid][pPremiumPoints] = cache_get_field_content_int(0, "PremiumPoints", mysql);
PlayerInfo[playerid][pPremiumAcount] = cache_get_field_content_int(0, "PremiumAcount", mysql);
PlayerInfo[playerid][pWalkie] = cache_get_field_content_int(0, "Walkie", mysql);
PlayerInfo[playerid][pWalkieOn] = cache_get_field_content_int(0, "WalkieOn", mysql);
PlayerInfo[playerid][pNumber] = cache_get_field_content_int(0, "Number", mysql);
PlayerInfo[playerid][pCellphone] = cache_get_field_content_int(0, "Cellphone", mysql);
PlayerInfo[playerid][pCellphoneOnline] = cache_get_field_content_int(0, "CellphoneOnline", mysql);
PlayerInfo[playerid][pPermGun] = cache_get_field_content_int(0, "PermGun", mysql);
PlayerInfo[playerid][pPhoneCredit] = cache_get_field_content_int(0, "PhoneCredit", mysql);
PlayerInfo[playerid][pClanMember] = cache_get_field_content_int(0, "ClanMember", mysql);
PlayerInfo[playerid][pClanRank] = cache_get_field_content_int(0, "ClanRank", mysql);
ClanInfo[clanid][cName] = cache_get_field_content_int(0, "ClanName", mysql);
SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
IsPlayerLogged[playerid] = 1;
SetTimerEx("RespawnPlayer", 500, false, "i", playerid);
}
This is the error line,its not my gamemode,its downloaded, and this is the whole script part in wich the error appears
Re: enums and database saving -
bosmania - 26.02.2019
and i assume i have to do something similar to this for the clan
case DIALOG_REGISTER:
{
if(!response) return Kick(playerid);
szQuery[0] = EOS;
PlayerInfo[playerid][pLevel] = 1;
IsPlayerLogged[playerid] = 1;
ShowPlayerDialog(playerid, DIALOG_LANGUAGE, DIALOG_STYLE_MSGBOX, "{FFFFFF}Registering", "Choose the language you speak.", "Romana", "English");
mysql_format(mysql, szQuery, 256, "INSERT INTO `users` (`Username`, `Password`, `Level`) VALUES ('%e', '%e', '1')", GetName(playerid), inputtext);
new Cache: result = mysql_query(mysql, szQuery);
new i = cache_insert_id();
cache_delete(result);
PlayerInfo[playerid][pID] = i;
}
Re: enums and database saving -
feartonyb - 26.02.2019
Quote:
ClanInfo[clanid][cName] = cache_get_field_content_int(0, "ClanName", mysql);
|
This is wrong as you are trying to read string as integrer and store it in another string.
Use
Quote:
cache_get_field_content(0, "ClanName", ClanInfo[clanid][cName]);
|
Do it for any other string you are loading from SQL, you don't need to store it in another variable than format the original one.
Also, remove
, mysql from cache_get_field_content_int
For any other issue I would need to see your code. Follow ****** instructions as he's more experienced.
Your code is messy and I would personaly change lots of things in it.
Re: enums and database saving -
bosmania - 27.02.2019
error 017: undefined symbol "clanid" it gives me this error when im using cache_get_field_content(0, "ClanName", ClanInfo[clanid][cName]); and i don't know where to define clan id like..what should i do