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(vehicleidstatus){
    new 
enginelightsalarmdoorsbonnetbootobjective;
    
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
    switch(
status){
        case 
0:{
            (
engine == 0) ? SetVehicleParamsEx(vehicleidVEHICLE_PARAMS_ONlightsalarmdoorsbonnetbootobjective) : SetVehicleParamsEx(vehicleidVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFalarmdoorsbonnetbootobjective); // ERROR
        
}
        case 
1:{
            (
lights == 0) ? SetVehicleParamsEx(vehicleidengineVEHICLE_PARAMS_ONalarmdoorsbonnetbootobjective) : SetVehicleParamsEx(vehicleidengineVEHICLE_PARAMS_OFFalarmdoorsbonnetbootobjective); // ERROR
        
}
        case 
2:{
            (
bonnet == 0) ? SetVehicleParamsEx(vehicleidenginelightsalarmdoorsVEHICLE_PARAMS_ONbootobjective) : SetVehicleParamsEx(vehicleidenginelightsalarmdoorsVEHICLE_PARAMS_OFFbootobjective); // ERROR
        
}
        case 
3:{
            (
boot == 0) ? SetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetVEHICLE_PARAMS_ONobjective) : SetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetVEHICLE_PARAMS_OFFobjective); // ERROR
        
}
        case 
4:{
            (
doors == 0) ? SetVehicleParamsEx(vehicleidenginelightsalarmVEHICLE_PARAMS_ONbonnetbootobjective) : SetVehicleParamsEx(vehicleidengineVEHICLE_PARAMS_OFFalarmdoorsbonnetbootobjective); // 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(vehicleidstatus){ 
    new 
enginelightsalarmdoorsbonnetbootobjective
    
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective); 
    switch(
status){ 
        case 
0:{ 
            (
engine 0) ? SetVehicleParamsEx(vehicleidVEHICLE_PARAMS_ONlightsalarmdoorsbonnetbootobjective) : SetVehicleParamsEx(vehicleidVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFalarmdoorsbonnetbootobjective); // ERROR 
        

        case 
1:{ 
            (
lights 0) ? SetVehicleParamsEx(vehicleidengineVEHICLE_PARAMS_ONalarmdoorsbonnetbootobjective) : SetVehicleParamsEx(vehicleidengineVEHICLE_PARAMS_OFFalarmdoorsbonnetbootobjective); // ERROR 
        

        case 
2:{ 
            (
bonnet 0) ? SetVehicleParamsEx(vehicleidenginelightsalarmdoorsVEHICLE_PARAMS_ONbootobjective) : SetVehicleParamsEx(vehicleidenginelightsalarmdoorsVEHICLE_PARAMS_OFFbootobjective); // ERROR 
        

        case 
3:{ 
            (
boot 0) ? SetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetVEHICLE_PARAMS_ONobjective) : SetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetVEHICLE_PARAMS_OFFobjective); // ERROR 
        

        case 
4:{ 
            (
doors 0) ? SetVehicleParamsEx(vehicleidenginelightsalarmVEHICLE_PARAMS_ONbonnetbootobjective) : SetVehicleParamsEx(vehicleidengineVEHICLE_PARAMS_OFFalarmdoorsbonnetbootobjective); // 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.