Using random
#1

pawn Code:
new rand = random(4);
   
    case 1: {
   
        gPlayerCheckpointStatus[playerid] = CHECKPOINT_TRASH1;
        SetPlayerCheckpoint(playerid, 1799.2505,-1808.7913,13.5402, 3);
        return 1;
    }
    case 2: {

        gPlayerCheckpointStatus[playerid] = CHECKPOINT_TRASH2;
        SetPlayerCheckpoint(playerid, 1907.1907,-1787.6948,13.5469, 3);
        return 1;
    }
    case 3: {

        gPlayerCheckpointStatus[playerid] = CHECKPOINT_TRASH3;
        SetPlayerCheckpoint(playerid, 1337.6495,-1773.3040,13.5469, 3);
        return 1;
    }
    case 4: {

        gPlayerCheckpointStatus[playerid] = CHECKPOINT_TRASH4;
        SetPlayerCheckpoint(playerid, 861.9600,-1384.0540,13.6971, 3);
        return 1;
    }
Whats wrong with this code?
Reply
#2

"random" starts from 0. So using "random(4)", your values are 0 to 3.
Reply
#3

Quote:
Originally Posted by SickAttack
View Post
"random" starts from 0. So using "random(4)", your values are 0 to 3.
Also I missed the switch

Thanks for helping.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)