2 simple questions
#1

Hey
1- how to get the random ? [Not Resolved yet]

for an example :
pawn Код:
new RandomBombPos = random(3); // choose Random Skin for swat
         switch (RandomBombPos) {
            case 0: SetPlayerCheckpoint(i,1229.9495,730.8387,11.1036,2.0);
            case 1: SetPlayerCheckpoint(i,1219.4697,728.7880,11.1036,2.0);
            case 2: SetPlayerCheckpoint(i,1231.9760,747.9662,11.1036,2.0);
    }
how to get the random SetCheckpoint that server chose ?

2-How to specify the right coordinations for attaching object ? I mean , I want to attach an object for player in his hand , how to get the position of its pos? Is there any FS or Program to done that ?[RESOLVED]


Thank you.
Reply
#2

The code you have posted will pick a random number between 0 and 2. So, with your switch statement, it will pick either case 0, case 1, or case 2 and set the checkpoint for whatever case was chosen. In order to get another random checkpoint, you need to do that same code again.

Not sure about your second question though. There's a "EditObject()" function that people are using to get the proper coordinates for these items; however I have yet to try making a system like this, or let alone use the EditObject() function.
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
The code you have posted will pick a random number between 0 and 2. So, with your switch statement, it will pick either case 0, case 1, or case 2 and set the checkpoint for whatever case was chosen. In order to get another random checkpoint, you need to do that same code again.

Not sure about your second question though. There's a "EditObject()" function that people are using to get the proper coordinates for these items; however I have yet to try making a system like this, or let alone use the EditObject() function.
For the 1st question , I meant how to get the random that server chose

and thanks for your repply
Reply
#4

What do you mean 'get the random'?

2. https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject
Reply
#5

[QUOTE=Saw®;2374678]For the 1st question , I meant how to get the random that server chose /QUOTE]

pawn Код:
new RandomBombPos = random(3);
RandomBombPos IS the number that the random(3) chose.
Reply
#6

Quote:
Originally Posted by MP2
Посмотреть сообщение
What do you mean 'get the random'?

2. https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject
I have three SetPlayerCheckpoint , so I wanted that server choose one of the three randomly , but how to get the one that the server chose ?

and for the Question 2: (the website u gave me )I've read it before so I copied this:
SetPlayerAttachedObject(playerid, 3, 1609, 2); //Attach a turtle to the playerid's head, in slot 3
Cool , but how to know the coordinates ? I don't to attach the object to the head... any good way to know all bodies part position ?

thanks for your repply
[quote=RealCop228;2374730]
Quote:
Originally Posted by Saw®
Посмотреть сообщение
For the 1st question , I meant how to get the random that server chose /QUOTE]

pawn Код:
new RandomBombPos = random(3);
RandomBombPos IS the number that the random(3) chose.
thank you
Yeah like this , but I must do like (if(RandomBombPos==1) ......) any other easy way?

thanks
Reply
#7

UP(more than 24hrs)
Reply
#8

rephrase question 1, please.
you want to know which random checkpoint was chosen, when... what?
..when the player enters the checkpoint?
..when the function ends?
or do you want to use that random number later, in a different function? in that case, you need to make the variable global, best for [MAX_PLAYERS];.
Reply
#9

Yea , I want to use it in other places in GM ,I explain : I have it in Public MapChange , wanna get the random & use it under onPlayerSpawn for example.
Reply
#10

if you cant do it that way do it another.
pawn Код:
new RandomCheckPointNum;
new Float:RandomCheckPoint[][3] = {
{1229.9495,730.8387,11.1036},
{1219.4697,728.7880,11.1036},
{1231.9760,747.9662,11.1036}
};

//then use it like this
SetPlayerCheckpoint(i,RandomCheckPoint[RandomCheckPointNum][0], RandomCheckPoint[RandomCheckPointNum][1], RandomCheckPoint[RandomCheckPointNum][2],2.0);
RandomCheckPointNum++; if(RandomCheckPointNum>= sizeof(RandomCheckPoint)) RandomCheckPointNum=0;//this is so the next one is not the same as the last one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)