SA-MP Forums Archive
MySQL - 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 (/showthread.php?tid=258389)



MySQL - StilThere - 30.05.2011

Hi all,

my question is, can I make this shorter
Код:
for(i = 0; i < MAX_PLAYERS; i++){
		if(IsPlayerConnected(i)){
			GetPlayerPos(i, Xc, Yc, Zc);
			positions[i][0] = Xc;
			positions[i][1] = Yc;
		}
		else{
			positions[i][0] = 3000;
		}
		new Query[1024];
		format(Query, sizeof(Query), "DELETE FROM `samp`.`locations` WHERE `locations`.`playerid` = %d;", i);
		mysql_query(Query);
		format(Query, sizeof(Query), "INSERT INTO `samp`.`locations` ( `playerid` , `X` , `Y` ) VALUES ( '%d', '%f', '%f' )", i, positions[i][0], positions[i][1]);
		mysql_query(Query); 
	}
The way it works now takes a lot of cpu, I guess there should be an easy way. But I don't exactly know how.

Help?