timer problem
#1

Can someone tell me why this only works for ID 0? Let's say im ID 1 and i start the timers and the 1st timer works well, but then the 2nd and the other ones makes the effects and messages using ID 0 instead any other ids.

pawn Код:
if(strcmp(cmd,"/robstore",true)==0)
    {
    if(PlayerData[playerid][illegaljob] == 1)
    {
    SendClientMessage(playerid,RED, "SERVER MESSAGE: You need to wait 2 hours before doing an illegal job again!");
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 1.0, -28.3137,-89.6030,1003.5469) && GetPlayerInterior(playerid) == 18)
    {
    new PlayerName[24]; // We create a variable which will contain the players name.
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof string, "%s jumps on the counter, opens it and starts taking the money, making a robbery.", PlayerName);
    SendClientMessageToAll(PURPLE, string);
    TogglePlayerControllable(playerid,0);
    SetPlayerPos(playerid,-27.0017,-91.6230,1003.5469);
    SetPlayerFacingAngle( playerid, 1.4434 );
    SetTimer("rob1", 5000, false); // Set a timer of 1000 miliseconds (1 second)
    return 1;
    }
    else if(IsPlayerInRangeOfPoint(playerid, 1.0, 2267.6003,1628.8484,1084.2448) && GetPlayerInterior(playerid) == 1)
    {
    new PlayerName[24]; // We create a variable which will contain the players name.
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof string, "%s walks downstairs, then puts on some gloves and breaks the glasses, taking the jewels.", PlayerName);
    SendClientMessageToAll(PURPLE, string);
    TogglePlayerControllable(playerid,0);
    SetPlayerPos(playerid,2267.6003,1628.8484,1084.2448);
    SetPlayerFacingAngle( playerid, 179.7100 );
    SetTimer("jewel1", 20000, false); // Set a timer of 1000 miliseconds (1 second)
    return 1;
    }
    else if(IsPlayerInRangeOfPoint(playerid, 1.0, 254.1106,73.6983,1003.6406) && GetPlayerInterior(playerid) == 6)
    {
    new PlayerName[24]; // We create a variable which will contain the players name.
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(string, sizeof string, "%s gets secretly inside the Police Department, then walks to the lockers.", PlayerName);
    SendClientMessageToAll(PURPLE, string);
    TogglePlayerControllable(playerid,0);
    SetPlayerPos(playerid,254.1106,73.6983,1003.6406);
    SetPlayerFacingAngle( playerid, 182.9650 );
    SetTimer("pd1", 5000, false); // Set a timer of 1000 miliseconds (1 second)
    return 1;
    }
    else
    {
    SendClientMessage(playerid, RED, "SERVER MESSAGE: You are not at any one of the right locations!");
    SendClientMessage(playerid, RED, "[ Locations : 24/7 - Jewelry - Police Station ]");
    }
    return 1;
    }


forward rob1(playerid);

public rob1(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,-14.8974,-85.8489,1003.5469);
    SetPlayerFacingAngle( playerid, 270.2626 );
    format(string, sizeof string, "%s counts the money, then runs to a corner, and starts grabbing items.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    SetTimer("rob2", 5000, false); // Set a timer of 1000 miliseconds (1 second)
    TogglePlayerControllable(playerid,0);
}

forward rob2(playerid);

public rob2(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,-18.0227,-74.3114,1003.5542);
    SetPlayerFacingAngle( playerid, 3.3234 );
    format(string, sizeof string, "%s puts the items in a corner, then runs to the other corner, grabbing items.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    SetTimer("rob3", 5000, false); // Set a timer of 1000 miliseconds (1 second)
    TogglePlayerControllable(playerid,0);
}

forward rob3(playerid);

public rob3(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,-25.2458,-82.6672,1003.5469);
    SetPlayerFacingAngle( playerid, 89.4909 );
    format(string, sizeof string, "%s rapidly moves to another side of the store, and takes the items as fast as he cans.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    SetTimer("rob4", 5000, false); // Set a timer of 1000 miliseconds (1 second)
    TogglePlayerControllable(playerid,0);
}

forward rob4(playerid);

public rob4(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,-37.3902,-75.7418,1003.5469);
    SetPlayerFacingAngle( playerid, 89.4909 );
    format(string, sizeof string, "%s grabs all the taken items into a bag, then ties it and runs away from the store.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    TogglePlayerControllable(playerid,1);
    PlayerData[playerid][illegaljob] = 1;
    GivePlayerMoney(playerid,800);
    SetPlayerWantedLevel(playerid,3);
    SetPlayerAttachedObject(playerid,3,1550,1,0.009999, -0.319999, 0.000000, 49.000000, 76.000000, 3.000000);
    SetTimer("illegaltime",1000*120, false); // 2 hours
}

forward pd1(playerid);

public pd1(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,255.3858,77.4126,1003.6406);
    SetPlayerFacingAngle( playerid, 267.2291 );
    format(string, sizeof string, "%s starts opening the lockers, finds some badges and throws them into the floor.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    TogglePlayerControllable(playerid,0);
    SetTimer("pd2",10000, false); // 10 seconds
}

forward pd2(playerid);

public pd2(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,258.5221,77.9362,1003.6406);
    SetPlayerFacingAngle( playerid, 274.1225 );
    format(string, sizeof string, "%s opens a locker and finds 200$ and a gun, but the gun is not loaded so he throws it away.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    TogglePlayerControllable(playerid,0);
    SetTimer("pd3",10000, false); // 10 seconds
}

forward pd3(playerid);

public pd3(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,236.6373,75.6131,1005.0391);
    SetPlayerFacingAngle( playerid, 95.4973 );
    format(string, sizeof string, "%s looks around the chief desk, then opens it and grabs his money, then looks for more money/items.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    TogglePlayerControllable(playerid,0);
    SetTimer("pd4",10000, false); // 10 seconds
}

forward pd4(playerid);

public pd4(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,256.9729,64.6562,1003.6406);
    SetPlayerFacingAngle( playerid, 269.6655 );
    format(string, sizeof string, "%s puts all the money in a bag, then leaves the police department", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    SetPlayerWantedLevel(playerid,5);
    SetPlayerAttachedObject(playerid,3,1550,1,0.009999, -0.319999, 0.000000, 49.000000, 76.000000, 3.000000);
    GivePlayerMoney(playerid,2400);
    PlayerData[playerid][illegaljob] = 1;
    TogglePlayerControllable(playerid,1);
    SetTimer("illegaltime",1000*120, false); // 2 hours
}

forward jewel1(playerid);

public jewel1(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,2267.6760,1637.6750,1084.2344);
    SetPlayerFacingAngle( playerid, 86.3358 );
    format(string, sizeof string, "%s grabs the jewels and puts it into a bag, then runs to another desk.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    TogglePlayerControllable(playerid,0);
    SetTimer("jewel2",20000, false); // 10 seconds
}

forward jewel2(playerid);

public jewel2(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,2270.4338,1646.5586,1084.2344);
    SetPlayerFacingAngle( playerid, 265.5643 );
    format(string, sizeof string, "%s hits the glass, then throws the jewels, then cleans his forehead from the sweat.", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    TogglePlayerControllable(playerid,0);
    SetTimer("jewel3",20000, false); // 10 seconds
}

forward jewel3(playerid);

public jewel3(playerid)
{
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    SetPlayerPos(playerid,2267.4971,1666.3905,1084.2445);
    SetPlayerFacingAngle( playerid, 9.5918 );
    format(string, sizeof string, "%s grabs the final jewels, then throws the gloves again and ties the back, and puts it at his back, running away", PlayerName);
    SendClientMessageToAll(PURPLE,string);
    SetPlayerWantedLevel(playerid,4);
    SetPlayerAttachedObject(playerid,3,1550,1,0.009999, -0.319999, 0.000000, 49.000000, 76.000000, 3.000000);
    GivePlayerMoney(playerid,2100);
    PlayerData[playerid][illegaljob] = 1;
    TogglePlayerControllable(playerid,1);
    SetTimer("illegaltime",1000*120, false); // 2 hours
}
Reply
#2

Use SetTimerEx because it has more parameters.

SetTimer will only call the function, it won't put any variable for playerid, which will make the script only work for id 0.

In your case:

SetTimerEx("rob1", 5000, false, "i", playerid);
Reply
#3

still didnt work, id 0 gets the message and effects
Reply
#4

You have to use this for each one of them like: pd1, jewel1 rob1, rob2 and all..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)