script only works for id 0
#1

Ive made an script if a player fails to steal a car mission failed pops up and the camera changes,
it all works perfect, but only for id 0.
How can i make that everybody's camera gets set etc.
Please help and explain me how to fix it.

pawn Код:
forward Deliver(playerid);
public Deliver(playerid)
{
    PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
                if(gTeam[playerid] == TEAM_DEFENDERS)
                {
                    GameTextForPlayer(playerid, "~g~ Mission Completed", 6000, 4);
                    GivePlayerMoney(playerid, 3000);
                    SetPlayerScore(playerid,GetPlayerScore(playerid)+3);
                    SetTimer("Finshed", 6000, 0);
                    SetPlayerCameraPos(playerid, 2576.2761,2265.6660,13.8203);
                    SetPlayerCameraLookAt(playerid, 2581.9424,2271.2832,11.9809);
                }
                else if(gTeam[playerid] == TEAM_ATTACKERS)
                {
                    GameTextForPlayer(playerid, "~r~ Mission Failed", 6000, 4);
                    SetPlayerCameraPos(playerid, 2576.2761,2265.6660,13.8203);
                    SetPlayerCameraLookAt(playerid, 2581.9424,2271.2832,11.9809);
                    SetTimer("Finsh",6000,false);
                }
    SetTimer("Finsh",6000,false);
    return 1;
}
Reply
#2

How does Deliver(playerid) be called?
By a timer?
If yes, you'll need to use SetTimerEx instead of SetTimer, to pass the variables.
pawn Код:
SetTimerEx("Deliver",60000,false,"d",playerid);
Like this.
Reply
#3

Quote:
Originally Posted by leong124
Посмотреть сообщение
How does Deliver(playerid) be called?
By a timer?
If yes, you'll need to use SetTimerEx instead of SetTimer, to pass the variables.
pawn Код:
SetTimerEx("Deliver",60000,false,"d",playerid);
Like this.
Thanks for your fast reply, but it didnt work

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    new playervehicleid = GetPlayerVehicleID(playerid);

    if(ObjectiveReached) return;

    if(playervehicleid == OBJECTIVE_VEHICLE && gTeam[playerid] == TEAM_ATTACKERS)
    {
        SendClientMessageToAll(COLOR_WHITE,"Attackers Win!");
        ObjectiveReached = 1;
        SetTimerEx("Deliver",500,false,"i",playerid);
        }
        return;
    }
Here does it start.
Reply
#4

Use a loop.
Reply
#5

Loop?
Reply
#6

Ive tried a loop but it didnt work, it even didnt load the next game so..
Reply
#7

pawn Код:
forward Deliver(playerid);
public Deliver(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
            if(gTeam[playerid] == TEAM_DEFENDERS)
            {
                GameTextForPlayer(playerid, "~g~ Mission Completed", 6000, 4);
                GivePlayerMoney(playerid, 3000);
                SetPlayerScore(playerid,GetPlayerScore(playerid)+3);
                SetTimer("Finshed", 6000, 0);
                SetPlayerCameraPos(playerid, 2576.2761,2265.6660,13.8203);
                SetPlayerCameraLookAt(playerid, 2581.9424,2271.2832,11.9809);
            }
            else if(gTeam[playerid] == TEAM_ATTACKERS)
            {
                GameTextForPlayer(playerid, "~r~ Mission Failed", 6000, 4);
                SetPlayerCameraPos(playerid, 2576.2761,2265.6660,13.8203);
                SetPlayerCameraLookAt(playerid, 2581.9424,2271.2832,11.9809);
                SetTimer("Finsh",6000,false);
            }
            SetTimer("Finsh",6000,false);
        }
    }
    return 1;
}
Try this...
Reply
#8

Doenst work..
Reply
#9

Then this would do it...

pawn Код:
forward Deliver(playerid);
public Deliver(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
            if(gTeam[i] == TEAM_DEFENDERS)
            {
                GameTextForPlayer(i, "~g~ Mission Completed", 6000, 4);
                GivePlayerMoney(i, 3000);
                SetPlayerScore(i,GetPlayerScore(i)+3);
                SetTimer("Finshed", 6000, 0);
                SetPlayerCameraPos(i, 2576.2761,2265.6660,13.8203);
                SetPlayerCameraLookAt(i, 2581.9424,2271.2832,11.9809);
            }
            else if(gTeam[i] == TEAM_ATTACKERS)
            {
                GameTextForPlayer(i, "~r~ Mission Failed", 6000, 4);
                SetPlayerCameraPos(i, 2576.2761,2265.6660,13.8203);
                SetPlayerCameraLookAt(i, 2581.9424,2271.2832,11.9809);
                SetTimer("Finsh",6000,false);
            }
            SetTimer("Finsh",6000,false);
        }
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by Hipflop
Посмотреть сообщение
Then this would do it...

pawn Код:
forward Deliver(playerid);
public Deliver(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
            if(gTeam[i] == TEAM_DEFENDERS)
            {
                GameTextForPlayer(i, "~g~ Mission Completed", 6000, 4);
                GivePlayerMoney(i, 3000);
                SetPlayerScore(i,GetPlayerScore(i)+3);
                SetTimer("Finshed", 6000, 0);
                SetPlayerCameraPos(i, 2576.2761,2265.6660,13.8203);
                SetPlayerCameraLookAt(i, 2581.9424,2271.2832,11.9809);
            }
            else if(gTeam[i] == TEAM_ATTACKERS)
            {
                GameTextForPlayer(i, "~r~ Mission Failed", 6000, 4);
                SetPlayerCameraPos(i, 2576.2761,2265.6660,13.8203);
                SetPlayerCameraLookAt(i, 2581.9424,2271.2832,11.9809);
                SetTimer("Finsh",6000,false);
            }
            SetTimer("Finsh",6000,false);
        }
    }
    return 1;
}
This will not work IMHO, even changing SetPlayerScore(i, ...) to SetPlayerScore(playerid, ...).
Imagine if there's 10 players, the player's score will be added by 3 * 10 = 30.

Now I get what you mean after reading it the second time.
You mean you want to set everyone's camera in the code.

pawn Код:
forward Deliver(playerid);
public Deliver(playerid)
{
    PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);//Only play the sound for the one who deliver the thing.
    GivePlayerMoney(playerid, 3000);//Only give the money to the one who deliver the thing.
    SetPlayerScore(playerid,GetPlayerScore(playerid) + 3);
    if(gTeam[playerid] == TEAM_DEFENDERS) SetTimer("Finshed", 6000, false);//This should be a global timer, so it shouldn't be called in a loop.
    else if(gTeam[playerid] == TEAM_ATTACKERS) SetTimer("Finsh",6000,false);
    for(new i = 0;i < MAX_PLAYERS;i++)
    {
        if(gTeam[i] == TEAM_DEFENDERS) GameTextForPlayer(i, "~g~ Mission Completed", 6000, 4);//Tell all the team members that they win.
        else if(gTeam[i] == TEAM_ATTACKERS) GameTextForPlayer(i, "~r~ Mission Failed", 6000, 4);//Tell all the team members that they lose.
        SetPlayerCameraPos(i, 2576.2761,2265.6660,13.8203);
        SetPlayerCameraLookAt(i, 2581.9424,2271.2832,11.9809);
        //SetTimer("Finsh",6000,false);(I don't know what it does, but probably it shouldn't be called here)
    }
    return 1;
}
Should be like this?
I don't know what the timers "Finshed" and "Finsh" do, so you'll need to provide the timers, or edit it on your own.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)