Problem with command -
Ld Est Ld - 13.02.2012
Hello,
I have a problem, if I want set player a vehicle it says Invalid ID all-the-time. -.-
pawn Код:
if((carModelID == 406-408, 416, 417, 423-425, 427, 428, 430-435, 437, 438, 441-444, 446-450, 452-457, 460-465, 468-473, 476, 481, 484-488, 493-499, 501-504, 509-515, 519-525, 528, 530-532, 537-539, 544, 548, 553, 556, 557, 563, 564, 568-574, 577, 578, 581-584, 586, 588, 590-599, 601, 604-608, 610, 611) && carModelID != 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid Car ID.");
Maybe I'm doing something wrong
No Compiler errors though.
Thanks!
Re: Problem with command -
Twisted_Insane - 13.02.2012
Erm, dude? Why do you use it like this?
Idk, maybe it's better this way, but I'd recommend to use cases:
This you'd do for any row of vehicles then, or you'd try it without cases in the if-statement:
pawn Код:
if((carModelID == 406..408, 416, 417, 423-425, 427, 428, 430..435, 437, 438, 441..444, 446..450, 452..457, 460..465, 468..473, 476, 481, 484..488, 493..499, 501..504, 509..515, 519..525, 528, 530..532, 537..539, 544, 548, 553, 556, 557, 563, 564, 568..574, 577, 578, 581..584, 586, 588, 590-599, 601, 604-608, 610, 611) && carModelID != 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid Car ID.");
Re: Problem with command -
Ld Est Ld - 13.02.2012
Quote:
Originally Posted by Twisted_Insane
pawn Код:
if((carModelID == 406..408, 416, 417, 423-425, 427, 428, 430..435, 437, 438, 441..444, 446..450, 452..457, 460..465, 468..473, 476, 481, 484..488, 493..499, 501..504, 509..515, 519..525, 528, 530..532, 537..539, 544, 548, 553, 556, 557, 563, 564, 568..574, 577, 578, 581..584, 586, 588, 590-599, 601, 604-608, 610, 611) && carModelID != 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid Car ID.");
|
Tried that way, it was give me always 4 errors.
I'm gonna try with cases
Re: Problem with command -
Twisted_Insane - 13.02.2012
And? Did it work?
Re: Problem with command -
Konstantinos - 13.02.2012
It's be used in cases not in if statement as you did it.
However, you need to check if the carModelID is one of the rest.
There are two ways. First with if statement or with case.
pawn Код:
switch( carModelID )
{
case 406 .. 408:
{
// Code
}
case 416:
{
// Code
}
// Rest.
pawn Код:
if( ( carModelID >= 406 && carModelID <=408 ) || carModelID == 416 || carModelID == 417 || ( carModelID >=423 && carModelID <= 425 ) || carModelID == 427 // Rest )
{
// Code
}
// Rest
Re: Problem with command -
Twisted_Insane - 13.02.2012
Eh, ^he answered my answer, you see? Gotta do it with cases! ^_^