STRCMP takes 2 seconds comparing a string with other.
#1

Hi,
I have the following problem with this code.

PHP код:
    if(!strcmp(Name(playerid), VehicleInfo[vehicleid][Owner], falsestrlen(Name(playerid))))
        {
            
SendClientMessage(playeridCOLOR_LIGHTRED"  You are driving your bought vehicle. Nobody else can use it");
        }
        else
        {
            
SendFMessage(playeridCOLOR_LIGHTRED"  This car is owned by %s. You can't use it"VehicleInfo[vehicleid][Owner]);
            
RemovePlayerFromVehicle(playerid);
        } 
The player gets kicked out the vehicle after 2 seconds.
Is there any way to make him get kicked faster?
-- Sorry for my bad english.
Reply
#2

Yes the way to make it faster is to do
pawn Код:
else
        {
            SendFMessage(playerid, COLOR_LIGHTRED, "  This car is owned by %s. You can't use it", VehicleInfo[vehicleid][Owner]);
            RemovePlayerFromVehicle(playerid);
            new Float:Pos[3];
            GetPlayerPos(playerid, Pos[0], Pos[1],Pos[2]);
            SetPlayerPos(playerid, Pos[0], Pos[1],Pos[2]+5);
        }
Although strcmp doesnt take two seconds to compare a string, the function that is "slower" is RemovePlayerFromVehicle.

Quote:
Originally Posted by Red_Dragon.
Посмотреть сообщение
Use a faster, easier and more efficient command processor. I recommend using zcmd or y_commands.
He doesnt want to make a command, he only wants to check if the player's vehicle is on his own.
Reply
#3

Use "OnPlayerEnterVehicle", it's called when a player begins to enter a vehicle.
Reply
#4

Quote:
Originally Posted by JustBored
Посмотреть сообщение
Yes the way to make it faster is to do
pawn Код:
else
        {
            SendFMessage(playerid, COLOR_LIGHTRED, "  This car is owned by %s. You can't use it", VehicleInfo[vehicleid][Owner]);
            RemovePlayerFromVehicle(playerid);
            new Float:Pos[3];
            GetPlayerPos(playerid, Pos[0], Pos[1],Pos[2]);
            SetPlayerPos(playerid, Pos[0], Pos[1],Pos[2]+5);
        }
Although strcmp doesnt take two seconds to compare a string, the function that is "slower" is RemovePlayerFromVehicle.



He doesnt want to make a command, he only wants to check if the player's vehicle is on his own.
Thanks man, It worked.
Reply
#5

Quote:
Originally Posted by DarkSlyder
Посмотреть сообщение
Use "OnPlayerEnterVehicle", it's called when a player begins to enter a vehicle.
Yeah , best solution .. and more roleplay .. Simply you don't have keys from veicle , you can't enter it
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)