SA-MP Forums Archive
Warning 215: Expression has no effect - 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)
+--- Thread: Warning 215: Expression has no effect (/showthread.php?tid=629477)



Warning 215: Expression has no effect - DuyDang2412 - 27.02.2017

PHP код:
SetVehicleStatus(vehicleid, status){
    new 
engine, lights, alarm, doors, bonnet, boot, objective;
    
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    switch(
status){
        case 
0:{
            (
engine == 0) ? SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective) : SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective); // ERROR
        
}
        case 
1:{
            (
lights == 0) ? SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective) : SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective); // ERROR
        
}
        case 
2:{
            (
bonnet == 0) ? SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, VEHICLE_PARAMS_ON, boot, objective) : SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, VEHICLE_PARAMS_OFF, boot, objective); // ERROR
        
}
        case 
3:{
            (
boot == 0) ? SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective) : SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective); // ERROR
        
}
        case 
4:{
            (
doors == 0) ? SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective) : SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective); // ERROR
        
}
    }
    return 
1;
} 
Help me please!


Re: Warning 215: Expression has no effect - iLearner - 27.02.2017

if statement before the conditions.


Re: Warning 215: Expression has no effect - DuyDang2412 - 27.02.2017

Can I use "?" and ":" condition? It is also a condition.


Re: Warning 215: Expression has no effect - Eoussama - 27.02.2017

Try this
PHP код:
SetVehicleStatus(vehicleid, status){ 
    new 
engine, lights, alarm, doors, bonnet, boot, objective; 
    
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); 
    switch(
status){ 
        case 
0:{ 
            (
engine = 0) ? SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective) : SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective); // ERROR 
        
} 
        case 
1:{ 
            (
lights = 0) ? SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective) : SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective); // ERROR 
        
} 
        case 
2:{ 
            (
bonnet = 0) ? SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, VEHICLE_PARAMS_ON, boot, objective) : SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, VEHICLE_PARAMS_OFF, boot, objective); // ERROR 
        
} 
        case 
3:{ 
            (
boot = 0) ? SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective) : SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective); // ERROR 
        
} 
        case 
4:{ 
            (
doors = 0) ? SetVehicleParamsEx(vehicleid, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective) : SetVehicleParamsEx(vehicleid, engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective); // ERROR 
        
} 
    } 
    return 
1; 
} 



Re: Warning 215: Expression has no effect - GoldenLion - 27.02.2017

https://sampforum.blast.hk/showthread.php?tid=216730 read about the ternary operator. Also I think it's better to use the if-else statement here.