[HELP] Bugged "/invite" command
#1

Hi guys! Recently, I made a /invite command for my RPG Server. It's a MYSQL server and I think there's a problem somewhere down here. What's happening is that the player is invited and everything is ok untill he relogs. Then, the skin and the team remains ok but [pMember] is not saving. So, he is a civilian with cop skin for example.

Код:
	if(strcmp(cmd, "/invite", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /invite [playerid/PartOfName]");
				return 1;
			}
			new para1;
			new ftext[20];
			para1 = ReturnUser(tmp);
			if (PlayerData[playerid][pLeader] >= 1 || PlayerData[playerid][pRank] == 6)
			{
			    if(IsPlayerConnected(para1))
			    {
			        if(para1 != INVALID_PLAYER_ID)
			        {
					    if (gTeam[para1]==TEAM_GREEN && PlayerData[para1][pMember] == 0 && PlayerData[para1][pFMember] == 255 || PlayerData[para1][pLeader] == 0)
					    {
             if(PlayerData[para1][pJob] > 0)
					        {
					            SendClientMessage(playerid, COLOR_GREY, "   Can't invite him, player has a Job !");
					            return 1;
					        }
					        if(PlayerData[playerid][pLeader] == 1) { PlayerData[para1][pTeam] = 2; gTeam[para1] = 2; ftext = "Police Department"; ChosenSkin[para1] = 280; SetPlayerSkin(para1, 280); }
					        else if(PlayerData[playerid][pLeader] == 2) { PlayerData[para1][pTeam] = 2; gTeam[para1] = 2; ftext = "FBI/ATF"; ChosenSkin[para1] = 286; SetPlayerSkin(para1, 286); }
					        else if(PlayerData[playerid][pLeader] == 3) { PlayerData[para1][pTeam] = 2; gTeam[para1] = 2; ftext = "National Guard"; ChosenSkin[para1] = 287; SetPlayerSkin(para1, 287); }
					        else if(PlayerData[playerid][pLeader] == 4) { PlayerData[para1][pTeam] = 1; gTeam[para1] = 1; ftext = "Paramedics"; ChosenSkin[para1] = 70; SetPlayerSkin(para1, 70); }
					        else if(PlayerData[playerid][pLeader] == 5) { PlayerData[para1][pTeam] = 5; gTeam[para1] = 5; ftext = "Mayor"; ChosenSkin[para1] = 258; SetPlayerSkin(para1, 120); }
					        else if(PlayerData[playerid][pLeader] == 6) { PlayerData[para1][pTeam] = 5; gTeam[para1] = 5; ftext = "Taxi Cab Company"; ChosenSkin[para1] = 120; SetPlayerSkin(para1, 258); }
					        else if(PlayerData[playerid][pLeader] == 7) { PlayerData[para1][pTeam] = 7; gTeam[para1] = 5; ftext = "School Instructors"; ChosenSkin[para1] = 153; SetPlayerSkin(para1, 153); }
					        else if(PlayerData[playerid][pLeader] == 8) { PlayerData[para1][pTeam] = 10; gTeam[para1] = 12; ftext = "Hitman Agency"; ChosenSkin[para1] = 127; SetPlayerSkin(para1, 127); }
					        else if(PlayerData[playerid][pLeader] == 9) { PlayerData[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "News Reporters"; ChosenSkin[para1] = 148; SetPlayerSkin(para1, 148); }
					        else if(PlayerData[playerid][pLeader] == 10) { PlayerData[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Tow Truck Company"; ChosenSkin[para1] = 255; SetPlayerSkin(para1, 255); }
					        else if(PlayerData[playerid][pLeader] == 11) { PlayerData[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Jamaican Posse"; ChosenSkin[para1] = 59; SetPlayerSkin(para1, 59); }
					        else if(PlayerData[playerid][pLeader] == 12) { PlayerData[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Bloods"; ChosenSkin[para1] = 67; SetPlayerSkin(para1, 67); }
					        else if(PlayerData[playerid][pLeader] == 13) { PlayerData[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Black Guerrila"; ChosenSkin[para1] = 102; SetPlayerSkin(para1, 102); }
					        else { return 1; }
							GetPlayerName(para1, giveplayer, sizeof(giveplayer));
							GetPlayerName(playerid, sendername, sizeof(sendername));
							PlayerData[para1][pMember] = PlayerData[playerid][pLeader];
							PlayerData[para1][pRank] = 1;
							printf("News: %s has invited %s to join %s.", sendername, giveplayer, ftext);
							format(string, sizeof(string), "   You have Joined the %s, you were invited by Leader %s", ftext, sendername);
							SendClientMessage(para1, COLOR_LIGHTBLUE, string);
							format(string,sizeof string, "INSERT INTO `factions` (`Player`,`Leader`,`Rank`)VALUES('%s','%s','1');",sendername,ftext);
							mysql_query(string);//acum zi comanda de /setrank,sau cum o fi
							format(string, sizeof(string), "   You have Invited %s to join the %s.", giveplayer,ftext);
							SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							SetPlayerInterior(para1,0);
							new rand = random(sizeof(gInviteSpawns));
							SetPlayerPos(para1, gInviteSpawns[rand][0], gInviteSpawns[rand][1], gInviteSpawns[rand][2]); // Warp the player
							SetPlayerFacingAngle(para1, gInviteSpawns[rand][3]);
							SetPlayerCameraPos(para1,gInviteSpawns[rand][0] + 3, gInviteSpawns[rand][1], gInviteSpawns[rand][2]);
							SetPlayerCameraLookAt(para1,gInviteSpawns[rand][0], gInviteSpawns[rand][1], gInviteSpawns[rand][2]);
							TogglePlayerControllable(para1, 0);
						    SelectChar[para1] = 255;
						    SelectCharID[para1] = PlayerData[para1][pMember];
						    SelectCharPlace[para1] = 1;
						    PlayerData[para1][pModel] = ChosenSkin[para1];
					    	PlayerData[para1][pChar] = ChosenSkin[para1];
						    SendClientMessage(para1, COLOR_LIGHTRED, "* Use 'next' to Select the char you want to use.");
						    SendClientMessage(para1, COLOR_LIGHTRED, "* If you've found the Char you want to use, type 'done'.");
						    new wakaname[25];
							GetPlayerName(para1,wakaname,25);
							new str[128];
							format(str,128,"UPDATE `users` SET `Cchar`='%d',`Team`='%d',`Model`='%d`,`Member`='%d' WHERE `name`='%s'",PlayerData[para1][pChar],PlayerData[para1][pTeam],PlayerData[para1][pModel],PlayerData[para1][pMember],wakaname);
							mysql_query(str);
						}
						else
						{
						    SendClientMessage(playerid, COLOR_GREY, "  That player is currently Wanted / a Different Team / or already a Family Member.");
						    return 1;
						}
					}
				}//not connected
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command(leaders only)!");
			}
		}
		return 1;
	}
Could you please tell me how to fix it?
Reply
#2

Have you checked your MySQL log for any errors?
Reply
#3

I didn't have the logs enabled from the begining, but, for now, nothing seems wrong. All the other MYSQL systems on my server are working perfectly perfectly fine, this is the only one I'm having problems with.

P.S: First of all i thought that the value changes but when the player reconnects the value resets back to 0 but nope. If i manually change the "Member" value from phpmyadmin, it saves and works perfectly fine.
Reply
#4

Any idea?
Reply
#5

Can you print this?

PHP код:
format(str,128,"UPDATE `users` SET `Cchar`='%d',`Team`='%d',`Model`='%d`,`Member`='%d' WHERE `name`='%s'",PlayerData[para1][pChar],PlayerData[para1][pTeam],PlayerData[para1][pModel],PlayerData[para1][pMember],wakaname);
print(
str);//Is the PlayerData[para1][pMember] correct or not?
                            
mysql_query(str); 
pMember is integer right?
Reply
#6

So: - I printed that and that's the result:
Код:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3z, ©2005-2014 SA-MP Team

[22:38:43] 
[22:38:43] Server Plugins
[22:38:43] --------------
[22:38:43]  Loading plugin: mysql
[22:38:43] 

  > MySQL plugin R5 successfully loaded.

[22:38:43]   Loaded.
[22:38:43]  Loading plugin: sscanf
[22:38:43] 

[22:38:43]  ===============================

[22:38:43]       sscanf plugin loaded.     

[22:38:43]          Version:  2.8.1        

[22:38:43]    © 2012 Alex "******" Cole  

[22:38:43]  ===============================

[22:38:43]   Loaded.
[22:38:43]  Loading plugin: streamer
[22:38:43] 

*** Streamer Plugin v2.7.5 by Incognito loaded ***

[22:38:43]   Loaded.
[22:38:43]  Loading plugin: crashdetect
[22:38:43]   CrashDetect must be loaded before 'streamer.DLL'
[22:38:43]   Failed.
[22:38:43]  Loading plugin: nativechecker
[22:38:43]   Loaded.
[22:38:43]  Loading plugin: Whirlpool
[22:38:43]  
[22:38:43]  ==================
[22:38:43]  
[22:38:43]   Whirlpool loaded
[22:38:43]  
[22:38:43]  ==================
[22:38:43]  
[22:38:43]   Loaded.
[22:38:43]  Loaded 5 plugins.

[22:38:43] 
[22:38:43] Ban list
[22:38:43] --------
[22:38:43]  Loaded: samp.ban
[22:38:43] 
[22:38:43] 
[22:38:43] Filterscripts
[22:38:43] ---------------
[22:38:43]   Loading filterscript 'Christmas.amx'...
[22:38:43]  
[22:38:43]  
[22:38:43]  
[22:38:43]  ======================================= 
[22:38:43]  |                                     | 
[22:38:43]  |        YSI version 4.00.0001        | 
[22:38:43]  |        By Alex "******" Cole        | 
[22:38:43]  |                                     | 
[22:38:43]  ======================================= 
[22:38:43]  
[22:38:43] 
 Christmas Filterscript Loaded! by Dimi

[22:38:43]   Loading filterscript 'cross.amx'...
[22:38:43]   Loading filterscript 'ACDealership.amx'...
[22:38:43]   Loaded 2 vehicles
[22:38:43]   Loaded 1 dealerships
[22:38:43]   Loading filterscript 'Apicultor.amx'...
[22:38:43]   Loading filterscript 'vehicle_speed_radars.amx'...
[22:38:43]   Unable to load filterscript 'vehicle_speed_radars.amx'.
[22:38:43]   Loading filterscript 'aimtest1.amx'...
[22:38:43]   Loaded 5 filterscripts.

[22:38:43]  
[22:38:43]  
[22:38:43]  
[22:38:43]  ======================================= 
[22:38:43]  |                                     | 
[22:38:43]  |        YSI version 4.00.0001        | 
[22:38:43]  |        By Alex "******" Cole        | 
[22:38:43]  |                                     | 
[22:38:43]  ======================================= 
[22:38:43]  
[22:38:43] 

[ -- ] [ Gamemode is Starting ] [ -- ]


[22:38:43] [MYSQL]: Connection succesful!
[22:38:45] -Houses: 67
[22:38:45] -Biz: 10
[22:38:46] -SBiz: 13
[22:38:48] -Turfs: 48
[22:38:49] -Papers: 9
[22:38:49] -Cars: 0
[22:38:49] -Pickups = 29
[22:38:49] 

[ -- ] [ Gamemode Loaded Succesfully ] [ -- ]
[22:38:49]  
[22:38:49]  
[22:38:49] Number of vehicle models: 113
[22:39:26] Incoming connection: 127.0.0.1:60469
[22:39:26] [join] AlexCez has joined the server (0:127.0.0.1)
[22:39:32] AlexCez has logged in.
[22:39:36] Warning: AlexCez (0) might be using ******! Distance in 1 second: 2264.995361 meters.
[22:40:00] Warning: AlexCez (0) might be using ******! Distance in 1 second: 2424.506835 meters.
[22:40:08] Warning: AlexCez (0) might be using ******! Distance in 1 second: 2763.942382 meters.
[22:40:21] Warning: AlexCez (0) might be using ******! Distance in 1 second: 4735.601562 meters.
[22:40:41] Incoming connection: 127.0.0.1:49404
[22:40:41] [join] AlexCeza has joined the server (1:127.0.0.1)
[22:40:47] AlexCeza has logged in.
[22:40:52] Warning: AlexCeza (1) might be using ******! Distance in 1 second: 2647.609863 meters.
[22:41:43] News: AlexCez has invited AlexCeza to join Police Department.
[22:41:43] UPDATE `users` SET `Cchar`='280',`Team`='2',`Model`='280`,`Member`='1' WHERE `name`='AlexCeza'
[22:41:45] Warning: AlexCeza (1) might be using ******! Distance in 1 second: 2827.449462 meters.
[22:41:46] [chat] [AlexCeza]: done
[22:41:47] Warning: AlexCeza (1) might be using ******! Distance in 1 second: 3954.250976 meters.
Everything seems fine. It printed it corectly but: ... same problem here, nothing but the skin updated.

pMember is an integer (a whole number) but it isn't declared with "new".
Reply
#7

Hm weird but i noticed something:

Код:
,`Model`='%d`,`Member`='%d'
Reply
#8

Oh, well thanks for finding such a hard to find mistake but nothing changed. Still, the "Member" isn't changing and i found out that so is the rank. /giverank works perfectly fine so it couldn't be an error on the mysql db or smth. else. The /invite command is the only one f..ed up here! I don't know why but it isn't updating the table.
Reply
#9

So wrong type of column in mysql/phpmyadmin? It should work. Print seems ok.
Reply
#10

It's a int(3) and rank column is int(2). Is it ok?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)