After TogglePlayerControllable in car server says: You are on FOOT!
#1

Hi guys, i want a little help with TogglePlayerControllable.
If i use TogglePlayerControllable(playerid, 0); in car, an get player state, server says: you are on foot, i writted auto salon, On public OnPlayerKeyStateChange, i use keys: Q(256) and E(64) to select a car, and he works not with Q and E, he works with mouse wheel, if i get on this moment player state, he says: YOU ARE ON FOOT. Dam., if i not use TogglePlayerControllable, he says: YOU ARE IN CAR. Yahoo. And Q and E keys are work correctly. What to do with TogglePlayerControllable? If i not use him, player accept for exit from vehicle or drive somewhere. Sorry for my bad English
Reply
#2

Just show us your code.
Reply
#3

Quote:
Originally Posted by youssefehab500
Посмотреть сообщение
Just show us your code.
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_LOOK_LEFT)
    {
        if(
InAutoSalon[playerid] == 1)
        {
            if(
IsPlayerInRangeOfPoint(playerid7, -1655.97851209.401020.9879))
            {
                new 
vehicleid GetPlayerVehicleID(playerid), vehiclem GetVehicleModel(vehicleid), car[MAX_PLAYERS];
                switch(
vehiclem)
                {
                    case 
400://Landstalker
                    
{
                        
DestroyVehicle(vehicleid);
                        
scolor[playerid] = -1;
                        
scolor1[playerid] = -1;
                        
car[playerid] = CreateVehicle(567, -1655.97851209.401020.9879227.2012, -1, -186400);
                        
SetVehicleVirtualWorld(car[playerid], world[playerid]);
                        
PutPlayerInVehEx(playeridcar[playerid], 0);
                        
SetPlayerCameraPos(playerid, -1650.49351210.381823.1794);
                        
SetPlayerCameraLookAt(playerid, -1655.97851209.401020.9879);
                        
format(stringsizeof(string), "~n~~n~~n~~n~~n~~n~~b~NAME: ~w~%s~n~~g~COST: ~w~%s~n~~y~COLOR1: ~w~%d ~y~COLOR2: ~w~%d"VehicleNames[GetVehicleModel(vehicleid)-400], VehiclePrice[GetVehicleModel(vehicleid)-400], scolor[playerid], scolor1[playerid]), GameTextForPlayer(playeridstring50003);
                        return 
true;
                    }
                }
            }
        }
    }
    return 
true;

Code really shitty, crappy... It works)) I optimize it later

And /buycar, code was to.. ya know.
PHP код:
    if(strcmp(cmd"/buycar"true) == 0)
    {
        if(
PlayerInfo[playerid][pHouseKey] == 999) return SendClientMessage(playeridCOLOR_GREY"You not have a house!");
        if(
PlayerInfo[playerid][pCarLic] != 1) return SendClientMessage(playeridCOLOR_GREY"You not have a car license!");
        if(
PlayerToPoint(2.0playerid562.4449, -1291.912517.2482))
        {
            if(
PlayerInfo[playerid][pCar] != 462) return ShowPlayerDialog(playerid1771DIALOG_STYLE_MSGBOX"Car buy""You are already have a car, will bought new car, old car was replace.\n Continue buy?""Yes""No");
            
TextDrawShowForPlayer(playeridDRAP);//Help Box
            
scolor[playerid] = -1;
            
scolor1[playerid] = -1;
            
vcolor1[playerid] = 0;
            
vcolor2[playerid] = 0;
            
AutoSalonSFAC[playerid] = 0;//One class in two cities
            
InAutoSalon[playerid] = 1;//check if you in salon
            
world[playerid] = random(32);
            new 
car[MAX_PLAYERS];
            
car[playerid] = CreateVehicle(400, -1655.97851209.401020.9879227.2012, -1, -186400);
            
PutPlayerInVehEx(playeridcar[playerid], 0);
            
Fuell[car[playerid]] = 200;
            
TogglePlayerControllable(playerid0);
            
SetPlayerCameraPos(playerid, -1650.49351210.381823.1794);
            
SetPlayerCameraLookAt(playerid, -1655.97851209.401020.9879);
            
SetVehicleVirtualWorld(car[playerid], world[playerid]);
            
SetPlayerVirtualWorld(playeridworld[playerid]);
            new 
vehbid GetPlayerVehicleID(playerid);
            
format(stringsizeof(string), "~n~~n~~n~~n~~n~~n~~b~NAME: ~w~%s~n~~g~COST: ~w~%s~n~~y~COLOR1: ~w~%d ~y~COLOR2: ~w~%d"VehicleNames[GetVehicleModel(vehbid)-400], VehiclePrice[GetVehicleModel(vehbid)-400], scolor[playerid], scolor1[playerid]), GameTextForPlayer(playeridstring50003);
            return 
true;
        }
        return 
true;
    } 
Reply
#4

Hello!

Does it work with this?
PHP код:
if(InAutoSalon[playerid] == 1
If yes, do you want delete this and work with another way?
Reply
#5

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Does it work with this?
PHP код:
if(InAutoSalon[playerid] == 1
If yes, do you want delete this and work with another way?
With this works, this variable check player in autosalon, if player not in salon, keys not working, well, pasting check in the car not helped...
Reply
#6

Show us the code that says "YOU ARE IN CAR" and "YOU ARE ON FOOT"
Reply
#7

After use TogglePlayerControllable(playerid, 0);
I check in OnPlayerUpdate player state
PHP код:
public OnPlayerUpdate(playerid)
{
    new 
state;
    
GetPlayerState(playeridstate);
    if(
state == 2SendClientMessage(playeridCOLOR_GREY"YOU ARE IN CAR");
    if(
state == 1SendClientMessage(playeridCOLOR_GREY"YOU ARE ON FOOT");
    return 
true;

Reply
#8

pawn Код:
// TOP OF SCRIPT
new PlayerState[MAX_PLAYERS];


// PUT THE REST SOMEWHERE
TogglePlayerControllableEx(playerid,toggle)
{
    PlayerState[playerid] = GetPlayerState(playerid);
    TogglePlayerControllable(playerid,toggle);
    return 1;
}

// USE ONLY WHEN FROZEN WITH TogglePlayerControllableEx,
// or else it will return PLAYERSTATE_NONE
GetPlayerStateWhileFrozen(playerid)
{
    return PlayerState[playerid];
}
Ooops changed the order on TogglePlayerControllableEx - CRUCIAL (fixed it now).
It Needs to get player state before toggleplayercontrollable and store it in PlayerState[playerid] :P
Reply
#9

Quote:
Originally Posted by liquor
Посмотреть сообщение
pawn Код:
// TOP OF SCRIPT
new PlayerState[MAX_PLAYERS];


// PUT THE REST SOMEWHERE
TogglePlayerControllableEx(playerid,toggle)
{
    PlayerState[playerid] = GetPlayerState(playerid);
    TogglePlayerControllable(playerid,toggle);
    return 1;
}

// USE ONLY WHEN FROZEN WITH TogglePlayerControllableEx,
// or else it will return PLAYERSTATE_NONE
GetPlayerStateWhileFrozen(playerid)
{
    return PlayerState[playerid];
}
Ooops changed the order on TogglePlayerControllableEx - CRUCIAL (fixed it now).
It Needs to get player state before toggleplayercontrollable and store it in PlayerState[playerid] :P
Ok, OnPlayerKeyStateChange says: you are on foot, what to get real state in OnPlayerKeyStateChange?
Reply
#10

So guys, thanks for all, i rewritted to Clickable Textdraws. Optimized today))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)