PDA

View Full Version : Help Please


Aimstar
10/03/2013, 07:12 AM
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == 425) //hunter
if(GetPlayerScore(playerid) < 1500)
if(GetVehicleModel(vehicleid) == 432) //rhino
if(GetPlayerScore(playerid) < 500)
{
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz+1.5);
RemovePlayerFromVehicle(playerid);
PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
SendClientMessage(playerid, COLOR_GREEN, "Your score is less for this vehicle");
return 1;
}
}

Can anyone help me?? Coz all cars are experiencing this Thanks :))

ulbi1990
10/03/2013, 07:22 AM
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==PLAYER_STATE_DRIVER || newstate==PLAYER_STATE_PASSENGER)
{
if(GetVehicleIModel(GetPlayerVehicleID(playerid))= =425 && GetPlayerScore(playerid)<1500) || (GetVehicleModel(GetPlayerVehicleID(playerid))==43 2 && GetPlayerScore(playerid)<500)
{
RemovePlayerFromVehicle(playerid); //allready is like slapping the player!
PlayerPlaySound(playerid, 1130);
SendClientMessage(playerid, COLOR_GREEN, "Your score is less for this vehicle");
}
}
return 1;
}

^Should work, wrote it without testing.

You need to use OnPlayerStateChange because OnPlayerEnterVehicle only gets called when the player enters the vehicle with "F" or "Enter", so he isn't in the vehicle which means you can't remove him.

Aimstar
10/03/2013, 07:57 AM
if(GetVehicleModel(GetPlayerVehicleID(playerid))== 425 && GetPlayerScore(playerid) < 1500) || (GetVehicleModel(GetPlayerVehicleID(playerid))==43 2 && GetPlayerScore(playerid)< 500);
{

I always get invalid Expression assume zero in this line :( Need Help

colonel-top
10/03/2013, 08:04 AM
Here is Examples For You

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Float:PosX,Float:PosY,Float:PosZ,model = GetVehicleModel(vehicleid);

if(GetVehicleModel(vehicleid) == 425 && GetPlayerScore(playerid) < 1500)
{
SendClientMessage(playerid, COLOR_RED, "You Need More Score to fly Hunter !");//messages goes to the player that he can't drive the hunter

GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player position
SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to Same Position << This Avoid Player Enter Vehicle
}
if(GetVehicleModel(vehicleid) == 432 && GetPlayerScore(playerid) < 500)
{
SendClientMessage(playerid, COLOR_RED, "You Need More Score to Drive Tank !");//messages goes to the player that he can't drive the tank

GetPlayerPos(playerid,PosX,PosY,PosZ);//getting player position
SetPlayerPos(playerid,PosX,PosY,PosZ);//setting player to Same Position << This Avoid Player Enter Vehicle
}
}

I hope its help you

ulbi1990
10/03/2013, 08:08 AM
@colonel-top
Sorry but are you dumb? I already told that you CAN'T remove a player while using the Callback OnPlayerEnterVehicle....

If you won't believe me read the SA:MP wiki.

OnPlayerEnterVehicle (http://wiki.sa-mp.com/wiki/OnPlayerEnterVehicle)

To remove a player from a vehicle does he NEED to be in a vehicle first.

Aimstar
10/03/2013, 08:11 AM
Cant understand yours Colonel Top

colonel-top
10/03/2013, 08:12 AM
@ulbi1990
Sorry Guy But I'm Using It And Its Work here and now
And im forget Delete RemovePlayerFromVehicle

Aimstar
10/03/2013, 08:13 AM
Ulbi i always get Invalid Expression,Assumed Zero how to fix it? if(GetVehicleModel(GetPlayerVehicleID(playerid)))= =425 && GetPlayerScore(playerid) < 1500) || (GetVehicleModel(GetPlayerVehicleID(playerid))==43 2 && GetPlayerScore(playerid)< 500);
{

ulbi1990
10/03/2013, 08:14 AM
Try this please:

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate==PLAYER_STATE_DRIVER || newstate==PLAYER_STATE_PASSENGER)
{
new Float:zPos[3];
GetPlayerPos(playerid,zPos[0],zPos[1],zPos[2]);
if(GetVehicleModel(GetPlayerVehicleID(playerid))== 425 && GetPlayerScore(playerid)<1500)
{
RemovePlayerFromVehicle(playerid); //allready is like slapping the player!
PlayerPlaySound(playerid, 1130,zPos[0],zPos[1],zPos[2]);
SendClientMessage(playerid, COLOR_GREEN, "Your score is less for this vehicle");
}
if(GetVehicleModel(GetPlayerVehicleID(playerid))== 432 && GetPlayerScore(playerid)<500)
{
RemovePlayerFromVehicle(playerid); //allready is like slapping the player!
PlayerPlaySound(playerid, 1130,zPos[0],zPos[1],zPos[2]);
SendClientMessage(playerid, COLOR_GREEN, "Your score is less for this vehicle");
}
}
return 1;
}

Sandiel
10/03/2013, 10:11 AM
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(GetPlayerVehicleId(playerid)) == 425) //hunter
{
if(GetPlayerScore(playerid)) > 1500)
{
new Floatlx, Floatly, Floatlz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz+1.5);
RemovePlayerFromVehicle(playerid);
PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
SendClientMessage(playerid, COLOR_GREEN, "Your score is too low for this vehicle");
}
}
else if(GetVehicleModel(GetPlayerVehicleId(playerid)) == 432) //Rhino
{
if(GetPlayerScore(playerid)) < 500)
{
new Floatlx, Floatly, Floatlz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz+1.5);
RemovePlayerFromVehicle(playerid);
PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
SendClientMessage(playerid, COLOR_GREEN, "Your score is too low for this vehicle!");
}
}
return 1;
}
Not tested but should work

RajatPawar
10/03/2013, 10:22 AM
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(GetPlayerVehicleId(playerid)) == 425) //hunter
{
if(GetPlayerScore(playerid)) > 1500)
{
new Floatlx, Floatly, Floatlz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz+1.5);
RemovePlayerFromVehicle(playerid);
PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
SendClientMessage(playerid, COLOR_GREEN, "Your score is too low for this vehicle");
}
}
else if(GetVehicleModel(GetPlayerVehicleId(playerid)) == 432) //Rhino
{
if(GetPlayerScore(playerid)) < 500)
{
new Floatlx, Floatly, Floatlz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz+1.5);
RemovePlayerFromVehicle(playerid);
PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
SendClientMessage(playerid, COLOR_GREEN, "Your score is too low for this vehicle!");
}
}
return 1;
}
Not tested but should work
You should use OnPlayerStateChange !