SA-MP Forums Archive
STRCMP takes 2 seconds comparing a string with other. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: STRCMP takes 2 seconds comparing a string with other. (/showthread.php?tid=454960)



STRCMP takes 2 seconds comparing a string with other. - Magic_Time - 31.07.2013

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.


Respuesta: STRCMP takes 2 seconds comparing a string with other. - JustBored - 31.07.2013

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.


Re: STRCMP takes 2 seconds comparing a string with other. - SimonItaly - 31.07.2013

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


Re: Respuesta: STRCMP takes 2 seconds comparing a string with other. - Magic_Time - 31.07.2013

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.


Re: STRCMP takes 2 seconds comparing a string with other. - Stereotype - 31.07.2013

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