problem with car lock script
#1

Hello, again some problems.
It doesn't have any errors, but it doesn't working ingame.
pawn Код:
if (strcmp(cmdtext, "/locker", true)==0)
{
 if(IsPlayerInAnyVehicle(playerid))
 {
  new State=GetPlayerState(playerid);
  if(State!=PLAYER_STATE_DRIVER)
  {
   SendClientMessage(playerid,0xFF004040,"You can only lock the doors as the driver.");
   return 1;
  }
  new i;
  for(i=0;i<MAX_PLAYERS;i++)
  {
   if(i != playerid)
   {
    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
   }
  }
  new lock;
  for(lock=0;i<MAX_PLAYERS;lock++)
  if(lock == 1)
        {
       SendClientMessage(playerid, 0xFF004040,"Tu jau esi aizsleedzis kaadu citu transporta liidzekli.");
    lock == 1;
             return 1;
  }
  if(lock == 0)
  {
   SendClientMessage(playerid, 0x33AA33AA,"Transporaliidzeklis aizsleegts.");
  }
  SendClientMessage(playerid, 0x33AA33AA, "Vehicle locked!");
  new Float:pX, Float:pY, Float:pZ;
  GetPlayerPos(playerid,pX,pY,pZ);
  PlayerPlaySound(playerid,1056,pX,pY,pZ);
 }
 else
 {
 SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
 }
 return 1;
    }
    if (strcmp(cmdtext, "/unlock", true)==0)
    {
 if(IsPlayerInAnyVehicle(playerid))
 {
 new State=GetPlayerState(playerid);
 if(State!=PLAYER_STATE_DRIVER)
 {
 SendClientMessage(playerid,0xFF004040,"You can only unlock the doors as the driver.");
 return 1;
 }
 new i;
 for(i=0;i<MAX_PLAYERS;i++)
 {
 SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
 }
 SendClientMessage(playerid, 0x33AA33AA, "Vehicle unlocked!");
 new Float:pX, Float:pY, Float:pZ;
 GetPlayerPos(playerid,pX,pY,pZ);
 PlayerPlaySound(playerid,1057,pX,pY,pZ);
 }
 else
 {
 SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
 }
 return 1;
}
 return 0;
           }

}
please help me fix this. big thank you, and respect.
Reply
#2

Give more informations! your script is long i don't wanna read it all
What CMD don't work ? when u use the CMD do you get the msg ?
Reply
#3

pawn Код:
CMD:vlock(playerid, params[])
{
 new oldcar = LastCar[playerid];
 new Float:cX, Float:cY, Float:cZ;
 GetVehiclePos(oldcar, cX, cY, cZ);
 new string[128];
 new engine,lights,alarm,doors,bonnet,boot,objective;
 GetVehicleParamsEx(oldcar, engine, lights, alarm, doors, bonnet, boot, objective);
 if(!IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
 {
  SendClientMessage(playerid,red,"You're not in range/in the Vehicle you last drove!");
  return 1;
 }
 else if(IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
 {
    if(doors != 1)
    {
     doors = 1;
     SetVehicleParamsEx(oldcar,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
      SendClientMessage(playerid, 0xFFFFFFAA, " You've locked the vehicle!");
      return 1;
    }
    else
    {
     doors = 0;
     SetVehicleParamsEx(oldcar,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
     SendClientMessage(playerid, 0xFFFFFFAA, " You've unlocked the vehicle!");
     return 1;
    }
 }
 return doors;
}
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    LastCar[playerid] = vehicleid;
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    LastCar[playerid] = vehicleid;
    return 1;
}
Reply
#4

Amine_Mejrhirrou, when i compile it doesnt show any erros but when i write a command in game it just show Unknown command.

thanks trapstar, but i need more simplier script.
Reply
#5

Maybe try this?

pawn Код:
if (strcmp(cmdtext, "/locker", true)==0)
{
 if(IsPlayerInAnyVehicle(playerid))
 {
  new State=GetPlayerState(playerid);
  if(State!=PLAYER_STATE_DRIVER)
  {
   SendClientMessage(playerid,0xFF004040,"You can only lock the doors as the driver.");
   return 1;
  }
  new i;
  for(i=0;i<MAX_PLAYERS;i++)
  {
   if(i != playerid)
   {
    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
   }
  }
  new lock;
  for(lock=0;i<MAX_PLAYERS;lock++)
  if(lock == 1)
        {
       SendClientMessage(playerid, 0xFF004040,"Tu jau esi aizsleedzis kaadu citu transporta liidzekli.");
    lock == 1;
             return 1;
  }
  if(lock == 0)
  {
   SendClientMessage(playerid, 0x33AA33AA,"Transporaliidzeklis aizsleegts.");
  }
  SendClientMessage(playerid, 0x33AA33AA, "Vehicle locked!");
  new Float:pX, Float:pY, Float:pZ;
  GetPlayerPos(playerid,pX,pY,pZ);
  PlayerPlaySound(playerid,1056,pX,pY,pZ);
 }
 else
 {
 SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
 }
 return 1;
    }
    if (strcmp(cmdtext, "/unlock", true)==0)
    {
 if(IsPlayerInAnyVehicle(playerid))
 {
 new State=GetPlayerState(playerid);
 if(State!=PLAYER_STATE_DRIVER)
 {
 SendClientMessage(playerid,0xFF004040,"You can only unlock the doors as the driver.");
 return 1;
 }
 new i;
 for(i=0;i<MAX_PLAYERS;i++)
 {
 SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
 }
 SendClientMessage(playerid, 0x33AA33AA, "Vehicle unlocked!");
 new Float:pX, Float:pY, Float:pZ;
 GetPlayerPos(playerid,pX,pY,pZ);
 PlayerPlaySound(playerid,1057,pX,pY,pZ);
 }
 else
 {
 SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
 }
 return 0;
}
 return 1;
           }

If this worked tell me
Reply
#6

Quote:
Originally Posted by James_Nick
Посмотреть сообщение
Maybe try this?

pawn Код:
if (strcmp(cmdtext, "/locker", true)==0)
{
 if(IsPlayerInAnyVehicle(playerid))
 {
  new State=GetPlayerState(playerid);
  if(State!=PLAYER_STATE_DRIVER)
  {
   SendClientMessage(playerid,0xFF004040,"You can only lock the doors as the driver.");
   return 1;
  }
  new i;
  for(i=0;i<MAX_PLAYERS;i++)
  {
   if(i != playerid)
   {
    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
   }
  }
  new lock;
  for(lock=0;i<MAX_PLAYERS;lock++)
  if(lock == 1)
        {
       SendClientMessage(playerid, 0xFF004040,"Tu jau esi aizsleedzis kaadu citu transporta liidzekli.");
    lock == 1;
             return 1;
  }
  if(lock == 0)
  {
   SendClientMessage(playerid, 0x33AA33AA,"Transporaliidzeklis aizsleegts.");
  }
  SendClientMessage(playerid, 0x33AA33AA, "Vehicle locked!");
  new Float:pX, Float:pY, Float:pZ;
  GetPlayerPos(playerid,pX,pY,pZ);
  PlayerPlaySound(playerid,1056,pX,pY,pZ);
 }
 else
 {
 SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
 }
 return 1;
    }
    if (strcmp(cmdtext, "/unlock", true)==0)
    {
 if(IsPlayerInAnyVehicle(playerid))
 {
 new State=GetPlayerState(playerid);
 if(State!=PLAYER_STATE_DRIVER)
 {
 SendClientMessage(playerid,0xFF004040,"You can only unlock the doors as the driver.");
 return 1;
 }
 new i;
 for(i=0;i<MAX_PLAYERS;i++)
 {
 SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
 }
 SendClientMessage(playerid, 0x33AA33AA, "Vehicle unlocked!");
 new Float:pX, Float:pY, Float:pZ;
 GetPlayerPos(playerid,pX,pY,pZ);
 PlayerPlaySound(playerid,1057,pX,pY,pZ);
 }
 else
 {
 SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
 }
 return 0;
}
 return 1;
           }

If this worked tell me
nope, not working
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)