26.10.2010, 10:10
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 ![Cheesy](images/smilies/biggrin.png)
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!
![Cheesy](images/smilies/biggrin.png)
Код:
{ 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; }