22.08.2018, 09:22
Ok guys, I made a gang everything works, but I can't really tell him the gang name with a cmd like /gang (you will see at the end of the thread), the text is empty even tho the gang name should be stored into player's enum.
/creategang
Assigning player data
Creating MySQL tables (I deleted 300 other tables and put only 'idgang' table only to be easy to understand and look wheres the problem. Don't worry if the string is 1500.)
After the player made his own gang name, I need to retrieve it into a text, like Your Gang: %s
And this is what it looks like:
Gang:
Just empty.
PHP код:
enum ENUM_PLAYER_DATA
{
GangID,
GangIDD,
NameGang,
OwnerGang,
};
new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA];
PHP код:
CMD:creategang(playerid, params[])
{
new gName[100], string[150], query[250];
if(pInfo[playerid][GangID] == 1) return SendClientMessage(playerid, COLOR_YELLOW, "(gang) You can't make a gang since you already are in a gang");
if(sscanf(params, "s[100]", gName)) return SendClientMessage(playerid, COLOR_YELLOW, "(gang) Syntax: /creategang (gang name)");
if(CheckGangByName(gName)) return SendClientMessage(playerid, COLOR_YELLOW, "(gang) A gang with this name is already taken");
mysql_format(g_SQL, query, sizeof query, "INSERT INTO `gangs` (GangID, GangName, GangOwner) VALUES (NULL, '%s', '%s')", gName, PlayerName[playerid]);
mysql_tquery(g_SQL, query);
format(string, sizeof(string), "You created: '%s'", gName);
SendClientMessage(playerid, -1, string);
pInfo[playerid][GangID] = 1;
mysql_format(g_SQL, query, sizeof query, "UPDATE `players` SET `idgang` = '1' WHERE `id` = '%d'", pInfo[playerid][ID]);
mysql_tquery(g_SQL, query);
return 1;
}
PHP код:
cache_get_value_int(0, "idgang", pInfo[playerid][GangID]);
cache_get_value_int(0, "GangID", pInfo[playerid][GangIDD]);
cache_get_value_int(0, "GangName", pInfo[playerid][NameGang]);
cache_get_value_int(0, "GangOwner", pInfo[playerid][OwnerGang]);
PHP код:
new query[1500] = "`idgang` mediumint(8) NOT NULL DEFAULT '0')");
mysql_tquery(g_SQL, "CREATE TABLE IF NOT EXISTS `gangs` (`GangID` INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, `GangName` VARCHAR(100) NOT NULL, `GangOwner` VARCHAR(25) NOT NULL)");
PHP код:
CMD:gang(playerid){
new str[160];
if(pInfo[playerid][GangID] == 1)
{
format(str, sizeof(str), "Gang: %s", pInfo[playerid][NameGang]);
SendClientMessage(playerid, -1, str);
}else{
SendClientMessage(playerid, -1, "you don't have any gang");
}
return 1;
}
Gang:
Just empty.