Seatbelt
#1

OK so i make like

Код:
 new seatbelton;
Код:
 new seatbeltoff;
Now how do i add to command so that turns to like 1, or 0 when you do the command?
Reply
#2

pawn Код:
new seatbelt[MAX_PLAYERS]; //We can set it to 1 when he has it on, and to 0 when he has it off. [MAX_PLAYERS] means that everyone can use the seatbelt command without interfering with others.
public OnPlayerCommandText(playerid,cmdtext[])
{
   if(strcmp(cmdtext,"/seatbelt",true) == 0)
   {
     if(IsPlayerInAnyVehicle(playerid)) //Checks if the player actually is in a vehicle
     {
       if(seatbelt[playerid] == 0) //Checks if our seatbelt variable is 0 (Put off)
       {
          seatbelt[playerid] = 1;
          SendClientMessage(playerid,0xE2C063FF,"You have put your seatbelt on.");
       }
       else //If he already has his seatbelt on (in this case, 'else' means 'if the player has his seatbelt on already'
       {
          seatbelt[playerid] = 0;
          SendClientMessage(playerid,0xE2C063FF,"You have put your seatbelt off.");
       }
     }
     else SendClientMessage(playerid,0xE2C063FF,"You aren't in any vehicle!");
     return 1;
   }
And if you'd like to make it more realistic;
pawn Код:
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
   seatbelt[playerid] = 0; //He just enters it.
   SendClientMessage(playerid,0xE2C063FF,"To put your seatbelt on, type /seatbelt.");
   return 1;
}

public OnPlayerExitVehicle(playerid,vehicleid)
{
   if(seatbelt[playerid] == 1)
   {
      seatbelt[playerid] = 0; //You can't take a seatbelt with you when you exit, right?
      SendClientMessage(playerid,0xE2C063FF,"You have exited your vehicle and put your seatbelt off.");
   }
   return 1;
}
Reply
#3

Thanks man, apperate tht.


**

I get some error's when doing this i edited this code out a little but one error i can't fix is that is is saying
Код:
 if(IsPlayerInAnyVehicle(playerid));
Код:
 error message: "error 036: empty statement"
That is the line the code above it is saying has an empty statement.


**

Nevermind fixed it.
Reply
#4

Quote:
Originally Posted by Steven82
Thanks man, apperate tht.


**

I get some error's when doing this i edited this code out a little but one error i can't fix is that is is saying
Код:
 if(IsPlayerInAnyVehicle(playerid));
Код:
 error message: "error 036: empty statement"
That is the line the code above it is saying has an empty statement.


**

Nevermind fixed it.
erm, ; at if? delete the ';'
Reply
#5

Nope, the command was coding was completly bugged, maybe we should just looks at a FS and learn from it.
Reply
#6

Quote:
Originally Posted by Steven82
Nope, the command was coding was completly bugged, maybe we should just looks at a FS and learn from it.
I've fixed it, try.
Reply
#7

razvan intra pe mess
Reply
#8

Quote:
Originally Posted by Steven82
Thanks man, apperate tht.


**

I get some error's when doing this i edited this code out a little but one error i can't fix is that is is saying
Код:
 if(IsPlayerInAnyVehicle(playerid));
Код:
 error message: "error 036: empty statement"
That is the line the code above it is saying has an empty statement.


**

Nevermind fixed it.
Sorry for that , and yes, it was if(IsPlayerInAnyVehicle(playerid))
Reply
#9

Ok great this works great thanks man.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)