Please Help Me !!
#1

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 !!
Reply
#2

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.
Reply
#3

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.
Reply
#4

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 ?
Reply
#5

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

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.
Reply
#7

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)
Reply
#8

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
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)