How to do it?
#1

Hello guys I have this enum for vehicle fuel:

pawn Код:
enum Car
{
    Float:F,
}
Can I add this also:
pawn Код:
enum Car
{
    Float:F,
        VW // Vehicle Windows
}
So I can script if vehicle windows are up or down?
Reply
#2

You are doing correct if you want VW to be an integer. :P

Код:
enum myEnum
{
    Float:fuel,
    vehWindow
}
new myVehEnum[maxVehicles][myEnum];
I read that you can add so vehWindow is a boolean by "bool:" tag just like with float but I would prefer integer as I might want to change the stances in a vehicle's window to be half-up maybe? Then with a bool I only have true or false to choose from, therefore I always use integers for objects that can have more than two behaviors.

Suggestion: If I were to be connect with your script in the future, I'd like to know what each attribute means without having to look at where you declared them, as in your "Float:F" doesn't really mean that it has to be fuel. Therefore to make the script readable, I suggest you change "F" to like "vehFuel" or "fuel" just to make it easier for people that will read the script and for yourself! Having lots of different attributes may make you confused later on once you have not used the enum for a while. :P Just a tip though.
Reply
#3

Removed.
Reply
#4

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
You are doing correct if you want VW to be an integer. :P

Код:
enum myEnum
{
    Float:fuel,
    vehWindow
}
new myVehEnum[maxVehicles][myEnum];
I read that you can add so vehWindow is a boolean by "bool:" tag just like with float but I would prefer integer as I might want to change the stances in a vehicle's window to be half-up maybe? Then with a bool I only have true or false to choose from, therefore I always use integers for objects that can have more than two behaviors.

Suggestion: If I were to be connect with your script in the future, I'd like to know what each attribute means without having to look at where you declared them, as in your "Float:F" doesn't really mean that it has to be fuel. Therefore to make the script readable, I suggest you change "F" to like "vehFuel" or "fuel" just to make it easier for people that will read the script and for yourself! Having lots of different attributes may make you confused later on once you have not used the enum for a while. :P Just a tip though.
Thank you, you was really helpful but one more question I'm about to script "windows system" so if windows will be closed and players will talk in car only they will see the message if windows will be open I will add PROXDETECTOR so other ppl will be able to see chat also..

How can I do that?

I tried something like this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(VW[GetPlayerVehicleID(playerid)] == 0) // VW = Vehicle Windows, this veriable will be replaced later..
        {
            return 1;
        }
    }
    return 1;
}
Umm I need to add loop here or smth ?
Thanks for help in advance
Reply
#5

I don't know how to do this but I'll give it a try (never done this before): Basically I think you'll make a "new" chat but without any command for it:

pawn Код:
forward inCarChat(carid, talk[]);
public inCarChat(carid, talk[])
{
    for(new i = 0; i <= MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            new targetCarID = GetPlayerVehicleID(i);
            if(carid == targetCarID)
            {
                SendClientMessage(i, color, talk);
            }
        }
    }
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if((IsPlayerInAnyVehicle(playerid)) && (winClosed[playerid] == 1)) //whatever way you choose to have the window fully closed
    {  
        new Tstring[128];
        format(Tstring, sizeof(Tstring), "[Closed window] %s says: %s", pName(playerid), text);
        new car = GetPlayerVehicleID(playerid);
        inCarChat(car, Tstring);
    }
   
    return 0; //Closes so NOTHING is printed out when someone talks in chat, meaning you will manually have to print it out (good for RP scripts!)
}
Reply
#6

Well I need to test my own, if it won't work I will try yours
Do you see any mistake ?

EDIT: this is only test version later I will add local chat function when windows will be open... I'm just using SendClientMessage to check if script is working..

pawn Код:
public OnPlayerText(playerid, text[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    new string[256];
    for(new i=0;i<MAX_PLAYERS;i++) // Loop
    {
        if(!IsPlayerConnected(i)) continue;
        {
            if(IsPlayerInAnyVehicle(i)) // We will check all players if they are in vehicle
            {
                if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)) // If the player is in the vehicle and if the player's vehicle is same vehicle ID as the guy who write the cmd...
                {
                    if(Carinfo[vehicleid][VehWin] == 0) // Closed
                    {
                        format(string, sizeof(string), "%s: %s",Name,text);
                        SendClientMessage(i,-1,string);
                        return 0;
                    }
                    if(Carinfo[vehicleid][VehWin] == 1) // Opened
                    {
                        format(string, sizeof(string), "%s: %s",Name,text);
                        SendClientMessage(playerid,COLOR_LIGHTGREEN, string);
                        return 0;
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#7

Might work, test it out. What I'm worried about is that
SendClientMessage(playerid,COLOR_LIGHTGREEN, string);

Is supposed to be

SendClientMessage(i,COLOR_LIGHTGREEN, string);

"if carinfo is opened then print out to id I with lightgreen color what has been said." where id I is someone inside your car.
Reply
#8

I will add PROXDETECTOR here so if windows will be open ppl outside of car will be able to hear also.. this SendClientMessage there is just for little test, I will test it out later
Reply
#9

One more question, how can I make if ppl out of car are talking and if a guy in car has closed window he won't see a chat from ppl that are talking outside of car ? :/
Reply
#10

Help please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)