Little Problem [+REP]
#1

Hello everybody i hope u can help me with a function ....

So i make a function to put a player in a vehicle after 4 seconds ..
The problem is the function doesn't put the player in vehicle .
And i want to know what's wrong in my function .

Function :

pawn Код:
public PutInCS(playerid)
{
    new Float:x, Float:y, Float:z, Float:angle, csveh;
    if(PlayerInDM[playerid][CS] == 1)
    {
        GetPlayerPos(playerid, x,y,z);
        GetPlayerFacingAngle(playerid, angle);
        csveh = CreateVehicle(444, x,y,z,angle, 24, 25, -1);
        PutPlayerInVehicle(playerid, csveh, 0);
        GameTextForPlayer(playerid, "~R~ Defeat all your opponents!", 4000, 1);
        TogglePlayerControllable(playerid, true);
    }
}

    SetTimerEx("PutInCS", 4000, false, "i", playerid); // That i use in command
Please help me [+REP!]
Reply
#2

I guess it's called but it never creates the vehicle because PlayerInDM[playerid][CS] is not 1 so make sure you set PlayerInDM[playerid][CS] to 1 in the command you set the timer.
Reply
#3

Try this, make sure that the variable specified is actually being set to something other than zero, otherwise the code you provided, and the code I gave will not work.
Код:
if(PlayerInDM[playerid][CS] != 0)
Reply
#4

Still the same problem

@ SGT.TheDarkness
pawn Код:
public PutInCS(playerid)
{
    new Float:x, Float:y, Float:z, Float:angle, csveh;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInDM[i][CS] == 1)
        {
            GetPlayerPos(i, x,y,z);
            GetPlayerFacingAngle(i, angle);
            csveh = CreateVehicle(444, x,y,z,angle, 24, 25, -1);
            PutPlayerInVehicle(i, csveh, 0);
            GameTextForPlayer(i, "~R~ Defeat all your opponents!", 4000, 1);
            TogglePlayerControllable(i, true);
        }
    }
}
@Konstantions i checked and when player type /de - > PlayerInDM[playerid][CS] = 1;
Reply
#5

In the /de command, you also set the timer? Just to be sure, debug it:
pawn Код:
public PutInCS(playerid)
{
    new Float:x, Float:y, Float:z, Float:angle, csveh;
    printf("DEBUG: PutInCS is being called.. playerid: %i", playerid);
    if(PlayerInDM[playerid][CS] == 1)
    {
        GetPlayerPos(playerid, x,y,z);
        GetPlayerFacingAngle(playerid, angle);
        csveh = CreateVehicle(444, x,y,z,angle, 24, 25, -1);
        PutPlayerInVehicle(playerid, csveh, 0);
        GameTextForPlayer(playerid, "~R~ Defeat all your opponents!", 4000, 1);
        TogglePlayerControllable(playerid, true);
    }
}
After executing the command and 4 seconds have passed (from the timer), does it print the message in the console?
Reply
#6

Yeah is print ... and don't work .. please anyone help ?
Reply
#7

So since it's called but it doesn't work, the problem is the one I mentioned. You don't set PlayerInDM[playerid][CS] to 1 before you call the timer.
Reply
#8

No i set look here the command

pawn Код:
CMD:cs(playerid, params[])
{
    new Float:gRandomPlayerSpawnsCS[5][0] =
    {
        {261.4781,3387.1755,127.5184},
        {267.6548,3341.4377,127.5184},
        {282.1428,3297.3818,132.4135},
        {215.6659,3296.2063,132.4135},
        {178.8598,3353.6843,136.3376}
       
    };
    new rand = random(sizeof(gRandomPlayerSpawnsCS));
    SetPlayerPos(playerid, gRandomPlayerSpawnsCS[rand][0], gRandomPlayerSpawnsCS[rand][1], gRandomPlayerSpawnsCS[rand][2]); // Warp the player
    ResetPlayerWeapons(playerid);
    SetPlayerVirtualWorld(playerid, 5);
    PlayerInDM[playerid][CS] = 1;
    SetPlayerVirtualWorld(playerid, 2);
    SetPVarInt(playerid, "PlayerInDM", 1);
    SendTeleport(playerid, "Car Sumo", "cs");
    SetPlayerHealth(playerid, 100);
    SendClientMessage(playerid, COLOR_ORANGE, "Welcome to {FF0000}Car Sumo");
    TogglePlayerControllable(playerid, false);
    SetTimerEx("PutInCS", 4000, false, "i", playerid);
    GameTextForPlayer(playerid, "~R~Please wait...", 4000, 1);
    return 1;
}
Reply
#9

Do you set PlayerInDM[playerid][CS] anywhere else? In a timer or callback that will set some other value rather than 1 before PutInCS is called for example.

By the way, it's:
pawn Код:
Float:gRandomPlayerSpawnsCS[5][3]
Reply
#10

No i didn't set anywhere
OnPlayerConnect CS = 0 ;
OnPlayerDisconnet CS = 0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)