SA-MP Forums Archive
Please Help Me !! - 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: Please Help Me !! (/showthread.php?tid=658898)



Please Help Me !! - SaMuRy - 15.09.2018

Quote:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

foreach (new i : Player)
{
if(vehdata[i][carexists] == 0)
{
SendClientMessage(playerid,COLOR_KRED,"You don't have a license ! --- /GetLicense");
SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
}
else if(userdata[playerid][license] && userdata[playerid][agra] == 1)
SetVehicleParamsEx(vehicleid, 1, 0, 0, 0, 0, 0, 0);
{
return 1;
}
}

Alright, so the code is working perfectly - When you don't have a license + agra you'll get a clientmessage "You don't have a license" but if you have a license it still get the same message... idk why :/ maybe you guys figured out
Thanks alot !!


Re: Please Help Me !! - Calisthenics - 15.09.2018

The callback provides you the playerid and vehicleid, the loop is unneeded.

You know when a player can drive because they got license so an else statement will work:
pawn Код:
if(userdata[playerid][license] && userdata[playerid][agra] == 1)
{
    SetVehicleParamsEx(vehicleid, 1, 0, 0, 0, 0, 0, 0);
}
else
{
    SendClientMessage(playerid,COLOR_KRED,"You don't have a license ! --- /GetLicense");
    SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
}
As for vehdata[i][carexists] variable, you used a player iterator for an unknown reason but its name indicates a vehicle-array.


Re: Please Help Me !! - spinu - 15.09.2018

vehdata[i][carexists]

should this be

userdata[playerid][license] or userdata[playerid][agra]

cause i think you want to check if the player has a license or not and than Send a Message.


Re: Please Help Me !! - SaMuRy - 15.09.2018

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
The callback provides you the playerid and vehicleid, the loop is unneeded.

You know when a player can drive because they got license so an else statement will work:
pawn Код:
if(userdata[playerid][license] && userdata[playerid][agra] == 1)
{
    SetVehicleParamsEx(vehicleid, 1, 0, 0, 0, 0, 0, 0);
}
else
{
    SendClientMessage(playerid,COLOR_KRED,"You don't have a license ! --- /GetLicense");
    SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
}
As for vehdata[i][carexists] variable, you used a player iterator for an unknown reason but its name indicates a vehicle-array.

Well... I did what you said but now it doesn't matter if I have a license or not, I can drive anyway why is that bro ?


Re: Please Help Me !! - Calisthenics - 15.09.2018

This means the player has license and agra set to 1 at all times. Do you reset the variables?


Re: Please Help Me !! - ShihabSoft - 15.09.2018

Well then check if the license variable is set to 1 and what is this userdata[playerid][agra] and check if this is set to 1.

If both are set to 1 then the player would be able to drive the vehicle if else they can't.


Re: Please Help Me !! - UFF - 15.09.2018

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
pawn Код:
if(userdata[playerid][license] && userdata[playerid][agra] == 1)
{
    SetVehicleParamsEx(vehicleid, 1, 0, 0, 0, 0, 0, 0);
}
else
{
    SendClientMessage(playerid,COLOR_KRED,"You don't have a license ! --- /GetLicense");
    SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, 0, 0, 0);
}
should be like this, if license is not a bool variable.
Код:
if(userdata[playerid][license] == 1 && userdata[playerid][agra] == 1)



Re: Please Help Me !! - SaMuRy - 15.09.2018

Quote:
Originally Posted by ShihabSoft
Посмотреть сообщение
Well then check if the license variable is set to 1 and what is this userdata[playerid][agra] and check if this is set to 1.

If both are set to 1 then the player would be able to drive the vehicle if else they can't.
How can i see? where is located I am sorry I am pretty new


Re: Please Help Me !! - AzaMx - 16.09.2018

PHP код:
if(userdata[playerid][license] == && userdata[playerid][agra] == 1)
{
    
SetVehicleParamsEx(vehicleid1000000);
}
else
{
    
SendClientMessage(playerid,COLOR_KRED,"You don't have a license ! --- /GetLicense");
    
SetVehicleParamsEx(vehicleid0000000);
   
{
return 
1