SA-MP Forums Archive
What am i doing wrong - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What am i doing wrong (/showthread.php?tid=660622)



What am i doing wrong - BiGuy - 08.11.2018

Hello i am trying to make a group system but i cant store group id, name and leader name in the variable it always return as blank here is my code:

PHP код:
stock CreateGroup(playeridgroupname[])
{
    new 
Query[208], string[128];
    
format(Querysizeof Query"INSERT INTO groups (name, leader, leaderid) VALUES ('%q', '%q', %d)"groupnamePlayerInfo[playerid][pName], PlayerInfo[playerid][pID]);
    
db_query(GroupDBQuery);
    
SendClientMessage(playerid0x00FF00FF"You have created a group!");
    new 
DBResultResult;
    
Result db_query(GroupDB"SELECT last_insert_rowid()");
    
GroupInfo[db_get_field_int(Result)][gID] = db_get_field_int(Result);
    
GroupInfo[db_get_field_int(Result)][gLeaderID] = PlayerInfo[playerid][pID];
    
GroupInfo[db_get_field_int(Result)][gMembers]++;
    
format(GroupInfo[db_get_field_int(Result)][gName], GroupInfo[db_get_field_int(Result)][gName], "%s"groupname);
    
format(GroupInfo[db_get_field_int(Result)][gLeader], GroupInfo[db_get_field_int(Result)][gLeader], "%s"PlayerInfo[playerid][pName]);
    
format(stringsizeof string"GroupName: {FF0000}%s"GroupInfo[db_get_field_int(Result)][gName]);
    
SendClientMessage(playerid, -1string);
    
format(stringsizeof string"GroupLeader: {FF0000}%s"GroupInfo[db_get_field_int(Result)][gLeader]);
    
SendClientMessage(playerid, -1string);
    
format(stringsizeof string"GroupID: {FF0000}%s"GroupInfo[db_get_field_int(Result)][gID]);
    
SendClientMessage(playerid, -1string);
    
    
PlayerInfo[playerid][pGroupID] = GroupInfo[db_get_field_int(Result)][gID];
    
PlayerInfo[playerid][pGroupRank] = 10;
    
printf("Group ID iS %d.",GroupInfo[db_get_field_int(Result)][gID]);
    
db_free_result(Result);
    
format(Querysizeof Query"INSERT INTO members (playerid, pname, prank, gid) VALUES (%d, '%q', %d, %d)"PlayerInfo[playerid][pID], PlayerInfo[playerid][pName], PlayerInfo[playerid][pGroupRank], PlayerInfo[playerid][pGroupID]);
    
db_query(GroupDBQuery);
    return 
1;

database logs:
Код:
[db_log_queries]: INSERT INTO groups (name, leader, leaderid) VALUES ('MyBigGrou
p', 'BiG', 1)
[db_log_queries]: SELECT last_insert_rowid()
Group ID iS 0.
[db_log_queries]: INSERT INTO members (playerid, pname, prank, gid) VALUES (1, '
BiG', 10, 0)
this is what i mean by blank:


just to be more specific the data stores in the database


Re: What am i doing wrong - cSharp - 08.11.2018

format(..)'s second parameter should be an integer defining the string's size.


Re: What am i doing wrong - BiGuy - 08.11.2018

Quote:
Originally Posted by cSharp
Посмотреть сообщение
format(..)'s second parameter should be an integer defining the string's size.
string size is already defined above with new string[128]; but you ignored my main problem and commented on something which is already working fine


Re: What am i doing wrong - cSharp - 08.11.2018

Quote:
Originally Posted by BiGuy
Посмотреть сообщение
string size is already defined above with new string[128]; but you ignored my main problem and commented on something which is already working fine
Don't be an ignorant cunt and act toxic, please. Explain me this if you so has given the string size to the format paramter:

pawn Код:
format(GroupInfo[db_get_field_int(Result)][gName], GroupInfo[db_get_field_int(Result)][gName], "%s", groupname);
You're the one on the forums requesting help, don't be a bitch when someone tells you the issue.
If you still can't figure out the issue, here, have a couple of eye hints:

Код:
format(GroupInfo[db_get_field_int(Result)][gName], GroupInfo[db_get_field_int(Result)][gName], "%s", groupname);
Код:
format(GroupInfo[db_get_field_int(Result)][gName], sizeof groupname, "%s", groupname);
And now you tell me, does the text appear? I'll go ahead and answer that for you - yes it does.


Re: What am i doing wrong - BiGuy - 08.11.2018

calm your tits down why are you mad? its my bad thanks for the help lol

btw i fixed it doing this:
PHP код:
    format(GroupInfo[db_get_field_int(Result)][gLeader], 24"%s"PlayerInfo[playerid][pName]);
    
format(GroupInfo[db_get_field_int(Result)][gName], 16"%s"groupname); 



Re: What am i doing wrong - v1k1nG - 08.11.2018

Quote:
Originally Posted by cSharp
Посмотреть сообщение
should be an integer
I doubt this
PHP код:
GroupInfo[db_get_field_int(Result)][gName
are bananas. Even if its value is 1 a letter should appear after formatting, and it doesn't.

Also
PHP код:
sizeof groupname 
is an indeterminate array size.


Re: What am i doing wrong - cSharp - 08.11.2018

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
I doubt this
PHP код:
GroupInfo[db_get_field_int(Result)][gName
are bananas. Even if its value is 1 a letter should appear after formatting, and it doesn't.

Also
PHP код:
sizeof groupname 
is an indeterminate array size.
fuck gives a fuck what the variable is, an integer is an integer.


Re: What am i doing wrong - v1k1nG - 08.11.2018

Keyboard lion(ess)