/carlock
#1

So, I've gotten stuck on this problem with the /carlock command. For some reason it won't detect that I'm the owner of the vehicle even if I am and leads to that I can't lock it even if I own it.

Код:
if(strcmp(cmd, "/carlock", true) ==0)
    {
     
      	if(GetClosestVehicle(playerid, 5))
		{
		for(new i = 0; i < MAX_PLAYERS; i++)
        {
          if (strmatch(CarSystem[GetClosestVehicle(playerid,5)][Carowner],pName(playerid)))
		  {
		  CarLock[GetClosestVehicle(playerid,5)] = 1;
		  SetVehicleParamsForPlayer(GetClosestVehicle(playerid,5),i,0,1);
		  new str[128];
		  format(str, sizeof(str), "*%s presses a key which locks the doors of the vehicle", pName(playerid));
		  ProxDetector(30.0,playerid,str,MECHAT,MECHAT,MECHAT,MECHAT,MECHAT);
		  return 1;
		  }
		  }

		}


		return 1;
		}
Reply
#2

Bumping..
Reply
#3

Try using strcmp instead of strmatch (https://sampwiki.blast.hk/wiki/Strcmp)
Reply
#4

Give this a try, should work...

pawn Код:
if(!strcmp(cmd, "/carlock", true, 8))
{
    if(GetClosestVehicle(playerid, 5))
    {
        for(new i = 0; i != MAX_PLAYERS; i++)
        {
            if(!strcmp(CarSystem[GetClosestVehicle(playerid,5)][Carowner], pName(playerid), true))
            {
                CarLock[GetClosestVehicle(playerid,5)] = 1;
                SetVehicleParamsForPlayer(GetClosestVehicle(playerid,5),i,0,1);
                new str[95];
                format(str, sizeof(str), "*%s presses a key which locks the doors of the vehicle", pName(playerid));
                ProxDetector(30.0,playerid,str,MECHAT,MECHAT,MECHAT,MECHAT,MECHAT);
            }
        }
    }
    return 1;
}
Reply
#5

what the hell is strmatch
Reply
#6

strmatch is a stock that I created which checks if the two strings matches each other. I'll try out the strcmp now so thank you.
Reply
#7

Quote:
Originally Posted by PotH3Ad
Посмотреть сообщение
Give this a try, should work...

pawn Код:
if(!strcmp(cmd, "/carlock", true, 8))
{
    if(GetClosestVehicle(playerid, 5))
    {
        for(new i = 0; i != MAX_PLAYERS; i++)
        {
            if(!strcmp(CarSystem[GetClosestVehicle(playerid,5)][Carowner], pName(playerid), true))
            {
                CarLock[GetClosestVehicle(playerid,5)] = 1;
                SetVehicleParamsForPlayer(GetClosestVehicle(playerid,5),i,0,1);
                new str[95];
                format(str, sizeof(str), "*%s presses a key which locks the doors of the vehicle", pName(playerid));
                ProxDetector(30.0,playerid,str,MECHAT,MECHAT,MECHAT,MECHAT,MECHAT);
            }
        }
    }
    return 1;
}
Did not work, I can now unlock and lock all of the vehicles. I also tried to remove the "!" but then I could also lock all vehicles.
Reply
#8

Bumb once again...
Reply
#9

Quote:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>


#if defined FILTERSCRIPT

if(strcmp(cmd, "/carlock", true) ==0)
{

if(GetClosestVehicle(playerid, 5))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if (strmatch(CarSystem[GetClosestVehicle(playerid,5)][Carowner],pName(playerid)))
{
CarLock[GetClosestVehicle(playerid,5)] = 1;
SetVehicleParamsForPlayer(GetClosestVehicle(player id,5),i,0,1);
new str[128];
format(str, sizeof(str), "*%s presses a key which locks the doors of the vehicle", pName(playerid));
ProxDetector(30.0,playerid,str,MECHAT,MECHAT,MECHA T,MECHAT,MECHAT);
return 1;
}
}

}
return 0;
}
#endif

Maybe so XD
Reply
#10

Why would it work with return 0;? Anyways, I think I'll try another system with this. Still feel free to post suggestions on fixing this command.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)