problem with saying gang name -
severance - 22.08.2018
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.
PHP код:
enum ENUM_PLAYER_DATA
{
GangID,
GangIDD,
NameGang,
OwnerGang,
};
new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA];
/creategang
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;
}
Assigning player data
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]);
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.)
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)");
After the player made his own gang name, I need to retrieve it into a text, like Your Gang: %s
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;
}
And this is what it looks like:
Gang:
Just empty.
Re: problem with saying gang name -
severance - 22.08.2018
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, '%e', '%e') LIMIT 1", gName, PlayerName[playerid]);
mysql_tquery(g_SQL, query);
pInfo[playerid][NameGang] = gName;
pInfo[playerid][OwnerGang] = PlayerName;
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' LIMIT 1", pInfo[playerid][ID]);
mysql_tquery(g_SQL, query);
return 1;
}
Tried making something like this, but it gives errors about strings
PHP код:
C:\Users\fomina.janett1919\Desktop\gtadm\gamemodes\gtadm.pwn(4256) : error 006: must be assigned to an array
C:\Users\fomina.janett1919\Desktop\gtadm\gamemodes\gtadm.pwn(4257) : error 006: must be assigned to an array
4256 and 4257:
PHP код:
pInfo[playerid][NameGang] = gName;
pInfo[playerid][OwnerGang] = PlayerName;
How do you make it to work, gName is already defined under array and PlayerName too.
Re: problem with saying gang name -
Rufio - 22.08.2018
1. You don't have to use gName, you can use params and check the size of params.
2. Why exactly are you using tquery when you aren't going to call a callback? Use mysql_query.
3. Are you sure your NameGang and OwnerGang variables are strings? Show us where you defined NameGang and OwnerGang.
4. Why are you using ' for integer values in your MySQL query? They are used for strings. You are only making your query bigger than it has to be.
5. Again, why are you using mysql_tquery when you aren't even calling a callback? Use mysql_query.
6. Why do you have oversized arrays? You are wasting memory for no reason. Your string isnt 150 bytes.
Re: problem with saying gang name -
severance - 22.08.2018
Not defined, how do you define it?
Re: problem with saying gang name -
Rufio - 22.08.2018
Quote:
Originally Posted by severance
Not defined, how do you define it?
|
What is not defined? Show us your pInfo enum.
Re: problem with saying gang name -
severance - 22.08.2018
PHP код:
enum ENUM_PLAYER_DATA
{
GangID,
GangIDD,
NameGang,
OwnerGang,
};
new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA];
Re: problem with saying gang name -
Rufio - 22.08.2018
Change it into this;
pawn Код:
enum ENUM_PLAYER_DATA
{
GangID,
GangIDD,
NameGang[100],
OwnerGang[MAX_PLAYER_NAME]
};
new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA];
Also change the things I've mentioned and it'll work just fine.
Re: problem with saying gang name -
severance - 23.08.2018
Sorry doesn't work, i don't know how to change those "things" on /creategang can someone tell me what's wrong out there ?
Re: problem with saying gang name -
JasonRiggs - 23.08.2018
Just under the command "creategang" add
PHP код:
format(pInfo[playerid][NameGang], sizeof(pInfo[playerid][NameGang]), "%s", gName);
and keep your enums like that
PHP код:
enum ENUM_PLAYER_DATA
{
GangID,
GangIDD,
NameGang[100],
OwnerGang[MAX_PLAYER_NAME]
};
new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA];
And the load isn't proper.. You're loading them as integers not as strings..
Re: problem with saying gang name -
severance - 23.08.2018
Like that?
PHP код:
CMD:creategang(playerid, params[])
{
new gName[MAX_PLAYER_NAME], 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);
format(pInfo[playerid][NameGang], sizeof(pInfo[playerid][NameGang]), "%s", gName);
pInfo[playerid][GangID] = 1;
pInfo[playerid][NameGang] = gName;
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;
}
4 errors in one line:
PHP код:
C:\Users\fomina.janett1919\Desktop\gtadm\gamemodes\gtadm.pwn(4263) : error 001: expected token: "]", but found "-identifier-"
C:\Users\fomina.janett1919\Desktop\gtadm\gamemodes\gtadm.pwn(4263) : warning 215: expression has no effect
C:\Users\fomina.janett1919\Desktop\gtadm\gamemodes\gtadm.pwn(4263) : error 001: expected token: ";", but found "]"
C:\Users\fomina.janett1919\Desktop\gtadm\gamemodes\gtadm.pwn(4263) : error 029: invalid expression, assumed zero
C:\Users\fomina.janett1919\Desktop\gtadm\gamemodes\gtadm.pwn(4263) : fatal error 107: too many error messages on one line
PHP код:
format(pInfo[playerid][NameGang], sizeof(pInfo[playerid][NameGang]), "%s", gName);