Spawn issues
#1

When I add
pawn Код:
new id;
    for (id = 0; id >=287; id++)
    {
        AddPlayerClass(id,2878.7581,2731.8020,10.8203,82.3289,0,0,0,0,0,0); // spawn1
    }
to my script, it spawns me in the middle of san andreas, yet when I get rid of the loop and do
pawn Код:
AddPlayerClass(0,2878.7581,2731.8020,10.8203,82.3289,0,0,0,0,0,0);
on its own in OnGameModeInit() it spawns me at those co-ordinates. Why?
Reply
#2

Hi biltong,

It appears as if you have only allowed all skins with ID 287 or above to spawn at those coords. Are you sure you are not simply attempting to spawn with the wrong skin?

TJ
Reply
#3

No, it's supposed to add every skin from 0 to 287.
Reply
#4

ok lets think

id = 0

aha, good, the variable id is 0 now (like it was after creation)

now the statment which must be true for the loop execution

id >= 287

or at the first call

0 >= 287

and that statment looks logically false

so the result of this false statment is that the for loop never gets executed and your script never calls the function AddPlayerClass

How to solve ? Just change the "bigger as" operator to a "smaller as" one
Reply
#5

So you're saying it should look like
pawn Код:
new id;
    for (id = 0; id <=287; id++)
    {
        AddPlayerClass(id,2878.7581,2731.8020,10.8203,82.3289,0,0,0,0,0,0); // spawn1
    }
?

Because the code is supposed to add one to id every time it is called until it is less than or equal to 287, which is id >= 287.

EDIT: Piece of code from Monster freeroam included in 0.2:
pawn Код:
for (id = 254; id <= 288; id++)
    {
        if (id == 265) id = 274; // Skip over the bad ones
        AddPlayerClass(id,389.8672,2543.0046,16.5391,173.7645,0,0,0,0,0,0);
    }
Reply
#6

ah, I think you are thinking that >= means "argument_1 is less or equal to argument_2", its <=
Reply
#7

Yeah, when I double checked the code from monster i facepalmed

Thanks for your help anyway :>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)