Hazard Warning via SetVehicleParamsEx -
Gama101 - 23.02.2011
Hello. I wanted to make a script which will turn off and on light automatically. I writed it but it doesn't works
Код:
#include <a_samp>
new timer1;
new timer2;
new engine,lights,alarm,doors,bonnet,boot,objective;
forward SwiatlaOn(playerid,vehicleid);
forward SwiatlaOFF(playerid,vehicleid);
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/awaryjne", cmdtext, true, 10) == 0)
{
timer1 = SetTimerEx("SwiatlaOn", 1000, 1, "i", playerid);
timer2 = SetTimerEx("SwiatlaOFF", 2000, 1, "i", playerid);
return 1;
}
if (strcmp("/awaryjne-off", cmdtext, true, 10) == 0)
{
KillTimer(timer1);
KillTimer(timer2);
return 1;
}
return 0;
}
public SwiatlaOn(playerid,vehicleid)
{
new veh = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
GivePlayerMoney(playerid,4000);
return 1;
}
public SwiatlaOFF(playerid,vehicleid)
{
new veh = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
GivePlayerMoney(playerid,5000);
return 1;
}
Re: Hazard Warning via SetVehicleParamsEx -
(SF)Noobanatior - 23.02.2011
try this
pawn Код:
#include <a_samp>
new timer1;
new bool:Swiatla[MAX_PLAYERS];
new engine,lights,alarm,doors,bonnet,boot,objective;
forward ToggleSwiatla(playerid);
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[]){
if (strcmp("/awaryjne", cmdtext, true, 10) == 0)return timer1 = SetTimerEx("ToggleSwiatla", 1000, 1, "i", playerid);
if (strcmp("/awaryjne-off", cmdtext, true, 10) == 0)return KillTimer(timer1);
return 0;
}
public ToggleSwiatla(playerid){
switch(Swiatla[playerid]){
case true:{
SwiatlaOFF(playerid);
Swiatla[playerid] = false;
}
case false:{
SwiatlaON(playerid);
Swiatla[playerid] = true;
}
}
}
stock SwiatlaON(playerid){
new veh = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
GivePlayerMoney(playerid,4000);
return 1;
}
stock SwiatlaOFF(playerid){
new veh = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
GivePlayerMoney(playerid,5000);
return 1;
}
Re: Hazard Warning via SetVehicleParamsEx -
Gama101 - 23.02.2011
Doesn't work. I typed /awaryjne and nothing happends ;(
Re: Hazard Warning via SetVehicleParamsEx -
(SF)Noobanatior - 24.02.2011
edited try my code again i forgot to change the timer function
Re: Hazard Warning via SetVehicleParamsEx -
Gama101 - 24.02.2011
Ok great
![Cheesy](images/smilies/biggrin.png)
It works now ;P Thanks