SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/08/2014, 04:39 PM   #1
Sarra
Huge Clucker
 
Join Date: Dec 2011
Posts: 220
Reputation: 7
Default switch

Hi!
pawn Code:
GetPlayerHealth(playerid, PlayerHealth);
switch(VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid])
    {
        case 5..20:
        {
       
        SetPlayerHealth(playerid, PlayerHealth-10);
        }
        case 20..50:
        {
       
        SetPlayerHealth(playerid, PlayerHealth-20);
        }
        case 50..100:
        {
   
        SetPlayerHealth(playerid, PlayerHealth-40);
        }
    }
This doesn't work since I repeated the "20" and the "50" so.. I want something like that
pawn Code:
if ((VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) >=5  && (VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) <20)

SetPlayerHealth(playerid, PlayerHealth-10);

else if ((VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) >=20  && (VehicleHealthAfter[playerid]-VehicleHealthBefore[playerid]) <50)

SetPlayerHealth(playerid, PlayerHealth-25);
// else if ....
If I can use something like "else if" in the "switch" it'll be okay
__________________
I'll +rep you only if you help me

Last edited by Sarra; 16/08/2014 at 07:40 PM.
Sarra is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch() bug?! TheSy Scripting Help 5 02/06/2014 04:49 PM
switch Don_Cage Scripting Help 2 10/02/2014 01:30 PM
Switch help PaulDinam Scripting Help 1 28/06/2012 08:14 PM
Switch + else? CrucixTM Help Archive 2 18/10/2010 08:23 PM
Why can I not do this switch? Memoryz Help Archive 2 13/09/2010 08:17 PM


All times are GMT. The time now is 10:14 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.