SA-MP Forums Archive
Respawn at Dm-areas...? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Respawn at Dm-areas...? (/showthread.php?tid=159431)



Respawn at Dm-areas...? - Sir_bomber - 13.07.2010

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?


Re: Respawn at Dm-areas...? - Hiddos - 13.07.2010

Place it at OnPlayerSpawn


Re: Respawn at Dm-areas...? - Sir_bomber - 13.07.2010

It is there...


Re: Respawn at Dm-areas...? - Hiddos - 13.07.2010

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


Re: Respawn at Dm-areas...? - Sir_bomber - 13.07.2010

huh? what you mean?


Re: Respawn at Dm-areas...? - Hiddos - 13.07.2010

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.


Re: Respawn at Dm-areas...? - Sir_bomber - 13.07.2010

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


Re: Respawn at Dm-areas...? - Hiddos - 13.07.2010

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.


Re: Respawn at Dm-areas...? - Sir_bomber - 13.07.2010

Still doesnt work... (I changed the random thingy...


Re: Respawn at Dm-areas...? - Joe_ - 13.07.2010

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;
}