Press 2 for engine. -
PepsiCola23 - 13.07.2015
I tried to convert my /engine to just press 2 .
This is what i tried :
PHP код:
if ((newkeys==KEY_SUBMISSION))
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You are not driving a vehicle.");
new string[128];
new vehid = GetPlayerVehicleID(playerid);
if(IsABike(vehid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You can't turn on engine on a bike!");
if(Gas[vehid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: This vehicle doesn't have fuel.");
new e,l,a,d,b,bo,o;
GetVehicleParamsEx(vehid,e,l,a,d,b,bo,o);
new name[25];
GetPlayerName(playerid, name, sizeof(name));
if(e == 0)
{
SetVehicleParamsEx(vehid,1,l,a,d,b,bo,o);
format(string, sizeof(string), "* %s porneste motorul vehiculului %s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else
{
SetVehicleParamsEx(vehid,0,l,a,d,b,bo,o);
format(string, sizeof(string), "* %s opreste motorul vehiculului %s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
This is the errors i get:
PHP код:
C:\Users\Paul23\Desktop\new gm\rG3-gamemode-master\gamemodes\rg3.pwn(20011) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Paul23\Desktop\new gm\rG3-gamemode-master\gamemodes\rg3.pwn(20092) : warning 209: function "S@@_OnPlayerKeyStateChange" should return a value
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Warnings.
Lines: 20011
PHP код:
new string[128];
20092: its just a bracket..
Re: Press 2 for engine. -
MBilal - 13.07.2015
PHP код:
if ((newkeys==KEY_SUBMISSION))
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You are not driving a vehicle.");
new Nstring[128];
new vehid = GetPlayerVehicleID(playerid);
if(IsABike(vehid)) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: You can't turn on engine on a bike!");
if(Gas[vehid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "{FFFFCC}Error: This vehicle doesn't have fuel.");
new e,l,a,d,b,bo,o;
GetVehicleParamsEx(vehid,e,l,a,d,b,bo,o);
new name[25];
GetPlayerName(playerid, name, sizeof(name));
if(e == 0)
{
SetVehicleParamsEx(vehid,1,l,a,d,b,bo,o);
format(Nstring, sizeof(Nstring), "* %s porneste motorul vehiculului %s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
ProxDetector(30.0, playerid, Nstring, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else
{
SetVehicleParamsEx(vehid,0,l,a,d,b,bo,o);
format(Nstring, sizeof(Nstring), "* %s opreste motorul vehiculului %s.", name,vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
ProxDetector(30.0, playerid, Nstring, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
And show your codes of OnPlayerKeyState
Re: Press 2 for engine. -
PepsiCola23 - 13.07.2015
I solved it,i change the name of the string and put return 1; at the end of the public
Re: Press 2 for engine. -
Michael B - 13.07.2015
I would suggest you to use
Shift instead of
2, as some vehicle models already use this key (e.g. horn, sirens, tog wheels for planes).
PHP код:
else if(newkeys & KEY_JUMP)
Regarding the errors, it seems that your variable "string[128]" is defined twice a the level where you get the error. Do you have another global variable around there, with the same properties?
At the second error, return a random value by using
return 1; at the end of the function/public.
Edit: Too late, you already did it....