When player do /joinrace disable cmd /v
#1

hey how do you do this?
When player do /joinrace disable cmd /v
and when player does /exitrace it enables??
Also when player gets out of car how do you make it so it atomaticly exits the race?
Reply
#2

can someone atleast tell me howto make it so when player gets out of car he leaves the raceplease?
Reply
#3

You'll have to create a new variable, which'll be true once the player joins race. Let me give you an example:
pawn Код:
new bool: pInRace[MAX_PLAYERS];

//Under OnPlayerConnect

pInRace[playerid] = false;

//Under OnPlayerDisconnect

pInRace[playerid] = false;

//In your /joinrace command

pInRace[playerid] = true;

//In your /v command
if(pInRace[playerid])
    return SendClientMessage(playerid, -1, "You can't use this command when you're in a race.");

//In your /leaverace command

pInRace[playerid] = false;
And for the other problem, something like:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
    {
        if(pInRace[playerid])
        {
            pInRace[playerid] = false;
            SendPlayerMessage(playerid, -1, "You left your vehicle and you've lost the race.");
            //The rest of your code here, insert whatever you want.
            return 1;
        }
    }
    return 1;
}
[/pawn]
Reply
#4

thx man but i decided i dont need to disable the v cmd so can you just make it when a player leaves the car he leaves the race?thank you.
Reply
#5

OnPlayerExitVehicle

Put the contents of your exitrace command here
Reply
#6

ok sorry i chould not have goten back to you fast but here you go.
pawn Код:
CMD:exitrace(playerid, params[])
{
    if(Joined[playerid] == true)
    {
        JoinCount--;
        Joined[playerid] = false;
        DestroyVehicle(CreatedRaceVeh[playerid]);
        DisablePlayerRaceCheckpoint(playerid);
        TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
        CPProgess[playerid] = 0;
        KillTimer(InfoTimer[playerid]);
        TogglePlayerControllable(playerid, true);
        SetCameraBehindPlayer(playerid);
        #if defined RACE_IN_OTHER_WORLD
        SetPlayerVirtualWorld(playerid, 0);
        #endif
    } else return SendClientMessage(playerid, RED, "<!> You are not in a race!");
    return 1;
}
Reply
#7

anyone help me?
Reply
#8

Here u go
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
   
    if(Joined[playerid] == true)
    {
        JoinCount--;
        Joined[playerid] = false;
        DestroyVehicle(CreatedRaceVeh[playerid]);
        DisablePlayerRaceCheckpoint(playerid);
        TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
        CPProgess[playerid] = 0;
        KillTimer(InfoTimer[playerid]);
        TogglePlayerControllable(playerid, true);
        SetCameraBehindPlayer(playerid);
        #if defined RACE_IN_OTHER_WORLD
        SetPlayerVirtualWorld(playerid, 0);
        #endif
        SendClientMessage(playerid, -1, "You left your vehicle and lost the race <!>");
    }  
    return 1;
}
gimme a rep if this works. Not Tested.
Reply
#9

nope not working
Reply
#10

One question, why did you use "bool"? And can you do it without "bool"?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)