SA-MP Forums Archive
Saving to SQLite - 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: Saving to SQLite (/showthread.php?tid=512899)



Saving to SQLite - Johnny_Robins - 13.05.2014

This succeeds at changing their name but doesn't save it in the sqlite database. Help Please

Код:
if(strcmp(cmd, "/setnamea3", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/PartOfName] [name]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(IsPlayerNPC(giveplayerid)) return 1;
			if(PlayerInfo[playerid][pAdmin] >=4)
			{
			    if(IsPlayerConnected(giveplayerid))
			    {
			        if(giveplayerid != INVALID_PLAYER_ID)
			        {
						tmp = strtok(cmdtext, idx);
						if(!strlen(tmp))
						{
							SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/PartOfName] [name]");
							return 1;
						}
                        if(SQL_AccountExists(tmp))
						{
							SendClientMessage(playerid, COLOR_GRAD1, "   That name is already registered !");
							return 1;
						}
						GetPlayerName(playerid, sendername, sizeof(sendername));
			            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						SetPlayerName(giveplayerid, tmp);
						OnPlayerSave(giveplayerid); // save player (in case server has a restart and fucks up their name)
						format(string, sizeof(string), "   You have renamed %s to %s !", giveplayer, tmp);
						SendClientMessage(playerid, COLOR_GREY, string);
						format(string, sizeof(string), "Your name has been changed from %s to %s.", giveplayer, tmp);
						SendClientMessage(giveplayerid, COLOR_YELLOW, string);
						format(string, sizeof(string), "%s has renamed %s to %s.", sendername, giveplayer, tmp);
						return 1;
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
			}
		}
		return 1;
	}