SA-MP Forums Archive
MySQL insert / bad code. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL insert / bad code. (/showthread.php?tid=70353)



MySQL insert / bad code. - Calgon - 24.03.2009

Код:
	if(strcmp(cmd, "/addhouse", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /addhouse [level] [price] [description]");
				return 1;
			}
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
				new id;
				id = strval(tmp);
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /addhouse [level] [price] [description]");
					return 1;
				}

				new id2;
				id2 = strval(tmp);

				if(id2 < 1 || id2 > 999999)
				{
					SendClientMessage(playerid, COLOR_GRAD1, "  The price must not be lower than $1 or higher than $999,999!");
					return 1;
				}

				new description;
				description = strval(tmp);
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /addhouse [level] [price] [description]");
					return 1;
				}

				new Float:plocx,Float:plocy,Float:plocz;
				GetPlayerPos(playerid, plocx, plocy, plocz);
				AddStaticPickup(1239, 2, plocx, plocy, plocz);
				format(string, sizeof(string), "INSERT INTO property (ent_x, ent_y, ent_z, description, level, price) VALUES('%s', '%s', '%s', '%s', '%s', '%s')", plocx, plocy, plocz, description, id, id2);
				samp_mysql_query(string);
				
				SendClientMessage(playerid, COLOR_YELLOW, "House successfully created!");
				return 1;

			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "Your not an administrator.");
			}
		}
		return 1;
	}
Hey, I made this code to use alongside CW-RP's game mode, however, it creates the pickup but doesn't insert the MySQL record, what am I to do?


Re: MySQL insert / bad code. - Calgon - 24.03.2009

Anyone? I urgently need this fixed.