SA-MP Forums Archive
Can someone explain to me - 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: Can someone explain to me (/showthread.php?tid=185800)



Can someone explain to me - karakana7 - 26.10.2010

So, I will start from that, that i was created race and there is one code, which check in what car you sitting, so it will know the car id and if this id is equal to 411(infernus) or 451(turismo), it'll create checkpoint and send message to player-Now you can start the race!But i found some indistinctness with some code lines-i created it myself and used a bit of other people knowledge.So first I will show you the code which do things, which i wrote recently and then after that i will ask you something
Код:
{
	new string[39];
	format(string, sizeof(string), "Now you can start the race!", 1, 2);
	vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
	if(vehicle == 411)
	{
	cp[playerid] = SetPlayerRaceCheckpoint(playerid, 0, -2334.7681,-2179.3489,35.1945, -2143.2742,-2006.9039,95.0157, 9);
	}
	else if(vehicle == 451)
	{
	cp[playerid] = SetPlayerRaceCheckpoint(playerid, 0, -2334.7681,-2179.3489,35.1945, -2143.2742,-2006.9039,95.0157, 9);
	SendClientMessage(playerid, 0xFFFFFFFF, string);
	return 1;
	}
	return 0;
}
Ok, so this is my code I was talking about, and actually you see some lines are bold, i did this, because i want to ask something about it.Ok, so is i'm right if i will delete these bold lines and variable string.And istead of string in the end of the code(where is function SendClientMessage) I write this message-"Now you can start the race!"-which was included into variable string before?I think it will be more optimised code, it will use less memory, because there will be less code, isn't i'm right?I know that in this format function are parameters like old and new state, but why i need it if code only will start, when i will be in a vehicle?Because when I'm on foot server will understand it and don't check the vehicle id.So i think you understand what i want to know.Thank you!


Re: Can someone explain to me - karakana7 - 26.10.2010

So there is no one who understand what i'm talking? DDD


Re: Can someone explain to me - Slice - 26.10.2010

Yeah you don't need format there.

However, if you have several "SendClientMessage" with the same message you should do:
pawn Код:
static string[ ] = "blablabla";

...

SendClientMessage( playerid, 0xFFFFFFFF, string );

...

SendClientMessage( playerid, 0xFFFFFFFF, string );



Re: Can someone explain to me - karakana7 - 26.10.2010

Quote:
Originally Posted by g_aSlice
Посмотреть сообщение
Yeah you don't need format there.

However, if you have several "SendClientMessage" with the same message you should do:
pawn Код:
static string[ ] = "blablabla";

...

SendClientMessage( playerid, 0xFFFFFFFF, string );

...

SendClientMessage( playerid, 0xFFFFFFFF, string );
Thank you man, now i understand it :P