Respawn at Dm-areas...?
#1

pawn Код:
if(DMArea[playerid] == 1)
    {
    if(PlayerDM[playerid] == 1)
    {
    new rand;
    rand = random(3);
    rand++ ;
    switch(rand)
    {
    case 1: SetPlayerPos(playerid,2231.8542,-1162.1888,1029.7969);
    case 2: SetPlayerPos(playerid,2240.6748,-1192.5139,1033.7969);
    case 3: SetPlayerPos(playerid,2198.5537,-1193.8461,1029.7969);
    case 4: SetPlayerPos(playerid,2189.0576,-1146.5973,1033.7969);
    }
    SetPlayerInterior(playerid,15);
    return 1;
    }
    else if(PlayerDM[playerid] == 2)
    {
    new rand;
    rand = random(3);
    rand++ ;
    switch(rand)
    {
    case 1: SetPlayerPos(playerid,277.7332,108.2940,1004.6172);
    case 2: SetPlayerPos(playerid,277.7538,116.6690,1008.8130);
    case 3: SetPlayerPos(playerid,221.1705,123.7949,999.0156);
    case 4: SetPlayerPos(playerid,240.0472,119.9434,1010.2188);
    }
But it still doesnt respawn...? Any tips?
Reply
#2

Place it at OnPlayerSpawn
Reply
#3

It is there...
Reply
#4

Try using the printf() function to check if his variables are set to what they should be I'd say.
Reply
#5

huh? what you mean?
Reply
#6

for example:

pawn Код:
public OnPlayerSpawn(playerid)
{
  printf("In-DM: %d",DMArea[playerid]);
  //bla
  return 1;
}
Prints '1' if the variable is true. I always use it to check what's wrong.
Reply
#7

what does it do? And how does that help to find the problem? It compiled fine btw...
Reply
#8

It helps to detect the cause, to show code that isn't reach, wrong variables, etc.

Also, the random function outputs a random amount, but it will never be the 'max' amount you enter.

random(3) will only do:
0
1
2
Not 3.
Reply
#9

Still doesnt work... (I changed the random thingy...
Reply
#10

Could you explain why you're using two varibles? or what they do?

This is a common example, should work / point you in the right direction.

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInDM[playerid]) // Checking if PlayerInDM is 1, add a ' ! ' infront of the varible to check for 0.
    {
        new
            rand = random(5);

    switch(rand)
    {
        case 1: SetPlayerPos(playerid, 0.0, 0.0, 0.0);
        case 2: SetPlayerPos(playerid, 0.0, 0.0, 0.0);
        case 3: SetPlayerPos(playerid, 0.0, 0.0, 0.0);
        case 4: SetPlayerPos(playerid, 0.0, 0.0, 0.0);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)