rentcar -
fonetic - 29.07.2014
Hello i have problems, getting /unrentcar command right so here is my rent car command.
pawn Код:
CMD:rentcar(playerid, params[])
{
if(GetPlayerState(playerid) == 2)
{
if(GetPlayerCash(playerid) < 9) return SCM(playerid, COLOR_LIGHTRED, "* You do not have enough money.");
SCM(playerid, COLOR_GOLD, "* You have rented this vehicle for $10. Type /engine to start it.");
rentingVehicle[playerid] = true;
GivePlayerCash(playerid, -10);
TogglePlayerControllable(playerid,1);
}
return 1;
and here is the command when i leave the car, under OnPlayerExitVehicle
pawn Код:
for(new i=0; i<5; i++)
{
if(IsPlayerInVehicle(playerid, rentCAR[i]))
{
new vehicle;
vehicle = GetPlayerVehicleID(playerid);
SCM(playerid, COLOR_GOLD, "* Your car was respawned, to give other players a chance for renting it).");
SetVehicleToRespawn(vehicle);
rentingVehicle[playerid] = false;
TogglePlayerControllable(playerid,1);
}
}
return 1;
}
I dont want it do be like that so i just deleted this,but know i can't unrent it,because can't get unrent command work. Can someone help me?
Re: rentcar -
Cannary2048 - 29.07.2014
You need to check the rent car id since /rentcar rents any vehicle the driver drives
pawn Код:
if(GetPlayerState(playerid) == 2 && IsPlayerInVehicle(playerid, rentCAR[i]))
under OnPlayerExitVehicle,
pawn Код:
if(rentingVehicle[playerid] == 1)
so it's basicly because the code checking if a player is in a vehicle while he's leaving a vehicle..
Re: rentcar -
fonetic - 29.07.2014
Thank you now i can unrent my vehicle, but what should i add to my unrentcar command so if engine is on it turns it off.
My unrentcar cmd
pawn Код:
CMD:unrentcar(playerid, params[])
{
for(new i=0; i<5; i++)
{
if(GetPlayerState(playerid) == 2 && IsPlayerInVehicle(playerid, rentCAR[i]))
{
rentingVehicle[playerid] = false;
TogglePlayerControllable(playerid,1);
}
}
return 1;
}
and my engine command
pawn Код:
CMD:engine(playerid,params[])
{
new string[124];
new id = GetVehicleID(GetPlayerVehicleID(playerid));
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerVehicleAccess(playerid, id) < 1)
return SendClientMessage(playerid, COLOR_RED, "* You don't have the keys for this vehicle!");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerState(playerid) == 2)
{
if(engine != 1)
{
SetVehicleParamsEx(vehicleid, 1, 1, alarm, doors, bonnet, boot, 0);
format(string, sizeof(string), "* %s turns the engine on.", GetName(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else if(engine != 0)
{
SetVehicleParamsEx(vehicleid, 0, 0, alarm, doors, bonnet, boot, 0);
format(string, sizeof(string), "* %s turns the engine off.", GetName(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
return 1;
}
I tried to get it work, but it's too hard for me.
Re: rentcar -
mjay768 - 29.07.2014
Why DOnt you try this?
Look at that 'else if'
Код:
CMD:engine(playerid,params[])
{
new string[124];
new id = GetVehicleID(GetPlayerVehicleID(playerid));
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerVehicleAccess(playerid, id) < 1)
return SendClientMessage(playerid, COLOR_RED, "* You don't have the keys for this vehicle!");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(GetPlayerState(playerid) == 2)
{
if(engine != 1)
{
SetVehicleParamsEx(vehicleid, 1, 1, alarm, doors, bonnet, boot, 0);
format(string, sizeof(string), "* %s turns the engine on.", GetName(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else if(engine == 1) //<<<<<<<<<<<<<<<<<<<< Here ++++++++++++++++++
{
SetVehicleParamsEx(vehicleid, 0, 0, alarm, doors, bonnet, boot, 0);
format(string, sizeof(string), "* %s turns the engine off.", GetName(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
return 1;
}
Re: rentcar -
fonetic - 29.07.2014
I tried it already but i got to many errors and i couldn't fix it, so maybe someone with better skills can help me
EDIT: I now have one error in my unrentcar code can someone try to see whats wrong?
Код:
C:\Users\Andy\Desktop\SAMP\RP\gamemodes\Roleplay.pwn(4493) : warning 217: loose indentation
C:\Users\Andy\Desktop\SAMP\RP\gamemodes\Roleplay.pwn(4502) : warning 217: loose indentation
C:\Users\Andy\Desktop\SAMP\RP\gamemodes\Roleplay.pwn(4506) : error 010: invalid function or declaration
unrentcar Command
pawn Код:
CMD:unrentcar(playerid, params[])
{
new string[124];
new vehicleid = GetPlayerVehicleID(playerid);
for(new i=0; i<5; i++)
{
if(GetPlayerState(playerid) == 2 && IsPlayerInVehicle(playerid, rentCAR[i]))
{
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
{
if(engine != 0)
{
SetVehicleParamsEx(vehicleid, 0, 0, alarm, doors, bonnet, boot, 0);
format(string, sizeof(string), "* %s turns the engine off.", GetName(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
}
rentingVehicle[playerid] = false;
TogglePlayerControllable(playerid,1);
}
}
return 1;
}
Re: rentcar -
mjay768 - 29.07.2014
Which ones the line 4506?
Re: rentcar -
fonetic - 29.07.2014
it's last line
Re: rentcar -
fonetic - 29.07.2014
Please can someone help?
Re: rentcar -
mjay768 - 29.07.2014
Try this.. This should work. You used an extra curly brace.

Now it will work.
Код:
CMD:unrentcar(playerid, params[])
{
new string[124];
new vehicleid = GetPlayerVehicleID(playerid);
for(new i=0; i<5; i++)
{
if(GetPlayerState(playerid) == 2 && IsPlayerInVehicle(playerid, rentCAR[i]))
{
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
{
if(engine != 0)
{
SetVehicleParamsEx(vehicleid, 0, 0, alarm, doors, bonnet, boot, 0);
format(string, sizeof(string), "* %s turns the engine off.", GetName(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
}
rentingVehicle[playerid] = false;
TogglePlayerControllable(playerid,1);
}
return 1;
}
Re: rentcar -
fonetic - 29.07.2014
Thanks man it worked