Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
I'm trying to make in my gamemode a script that does so that if you enter a bus(Canny) and speed over 60mph,it shows you a dialog that on your car has been planted a bomb,and if you slow down below 50mph it blows up.I have the PAWn script with no errors,but in-game it's not working,please HELP me fast(as you didn't asnwers the other topics at least answer this one :P):
pawn Код:
#define DIALOG_INFERNALRACE 5
#include <a_samp>
public OnPlayerEnterVehicle(playerid,vehicleid, ispassenger)
{
new Float:x, Float:y, Float:z;
GetVehicleModel(vehicleid);
if(vehicleid == 431)
{
GetVehicleVelocity(vehicleid,x,y,z);
if(GetVehicleVelocity(vehicleid,x,y,z) == x*1.5,y*1.5,z*1.5)
{
ShowPlayerDialog(playerid,5,DIALOG_STYLE_MSGBOX,"Infernal Race","A bomb has been planted on your bus,\nand if you slow down below 50mph,\nyou will be blowed up","Accept","Accept");
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==5)
{
if(response==1)
{
new vehicleid=GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
if(GetVehicleVelocity(vehicleid,x,y,z) == x*1.5,y*1.5,z*1.5)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetVehicleVelocity(vehicleid,x,y,z) < x*0.5,y*0.5,z*0.5)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
if(response==1)
{
new vehicleid=GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
if(GetVehicleVelocity(vehicleid,x,y,z) == x*1.5,y*1.5,z*1.5)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetVehicleVelocity(vehicleid,x,y,z) < x*0.5,y*0.5,z*0.5)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
}
(other dialogs following that's why no return)
So no errors when compiling,but it's not working,what' s wrong?
HELP!!!
Re: Please,help me with this FAST!!! -
Markx - 19.04.2011
Use [ pawn ] [ / pawn ] tags
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
where to use them exaclty please(and thanks for answer)
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
opppppps lol i know what u meant sorry,i didn't read well what u said xDD
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
ok tell me now the problem
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
or at least if you could try that on your gamemode,it gives you no error when compiling,but it simply does not work on-game
Re : Please,help me with this FAST!!! -
Vukilore - 19.04.2011
First:
pawn Код:
ShowPlayerDialog(playerid,5,DIALOG_STYLE_MSGBOX,"Infernal Race","A bomb has been planted on your bus,\nand if you slow down below 50mph,\nyou will be blowed up","Accept","");
Like this, you also need "If reponse = 1" so go delete reponse 0.
Finally i don't have any idea, sorry
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
I'll try it thanks
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
not working maybe thre's problem related to velocity float values,anyway still waiting for help
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
This is the modifed script,as on another topic "Vince" said that OnPlayerEnterVehicle is very different from OnPlayerStateChange.So this is the new script:
pawn Код:
#include <a_samp>
#define DIALOG_INFERNALRACE 5
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid=GetPlayerVehicleID(playerid);
GetPlayerState(playerid);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetVehicleModel(vehicleid);
if(vehicleid == 431)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vehicleid,x,y,z);
if(GetVehicleVelocity(vehicleid,x,y,z) == x*1.5,y*1.5,z*1.5)
{
ShowPlayerDialog(playerid,5,DIALOG_STYLE_MSGBOX,"Infernal Race","A bomb has been planted on your bus,\nand if you slow down below 50mph,\nyou will be blowed up","Accept","Accept");
}
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==5)
{
if(response==1)
{
new vehicleid=GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) == x*1.5,y*1.5,z*1.5)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) < x*0.5,y*0.5,z*0.5)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
if(response==1)
{
new vehicleid=GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) == x*1.5,y*1.5,z*1.5)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) < x*0.5,y*0.5,z*0.5)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
}
I'm waiting especially for help from Vince,as maybe he's good at Vehicle Scripts,and I wanna know(wich is probably the problem)if the float values of GetVehicleVelocity are correct.
Note:No errors when compiling.'
HELP!!!
Re: Please,help me with this FAST!!! -
Vince - 19.04.2011
GetVehicleVelocity just doesn't work like that. You need to parse them together to get a usable result (speed).
Use this function to determine the speed of a vehicle:
pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh = true)
{
new
Float:xx,
Float:yy,
Float:zz,
Float:pSpeed;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
}
else
{
GetPlayerVelocity(playerid,xx,yy,zz);
}
pSpeed = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
return kmh ? floatround((pSpeed * 195.12)) : floatround((pSpeed * 121.9));
}
Use:
For km/h:
new speed = GetPlayerSpeed(playerid);
for mph:
new speed = GetPlayerSpeed(playerid, false);
Re: Please,help me with this FAST!!! -
Gertin - 19.04.2011
pawn Код:
if(dialogid==5)
{
new vehicleid=GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
if(response)
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) == x*1.5,y*1.5,z*1.5)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) < x*0.5,y*0.5,z*0.5)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
if(!response)
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) == x*1.5,y*1.5,z*1.5)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z) < x*0.5,y*0.5,z*0.5)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
}
Use that too ...
Re: Please,help me with this FAST!!! -
alpha500delta - 19.04.2011
Ehm, one little thing, you have defined dialogid 5, but you're still using 5, not the define... why?
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
Message deleted!!!
Re: Please,help me with this FAST!!! -
Cjgogo - 19.04.2011
Script last modified(by indication from Vince),still not working:
pawn Код:
#include <a_samp>
#define DIALOG_INFERNALRACE 5
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid=GetPlayerVehicleID(playerid);
GetPlayerState(playerid);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetVehicleModel(vehicleid);
if(vehicleid == 431)
{
GetPlayerSpeed(playerid,true);
if(GetPlayerSpeed(playerid,true) > 60)
{
ShowPlayerDialog(playerid,5,DIALOG_STYLE_MSGBOX,"Infernal Race","A bomb has been planted on your bus,\nand if you slow down below 50mph,\nyou will be blowed up","Accept","Accept");
}
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==5)
{
if(response==1)
{
new vehicleid=GetPlayerVehicleID(playerid);
GetPlayerSpeed(playerid,true);
if(GetPlayerSpeed(playerid,true) > 60)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetPlayerSpeed(playerid,true) < 50)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
if(response==1)
{
new vehicleid=GetPlayerVehicleID(playerid);
GetPlayerSpeed(playerid,true);
if(GetPlayerSpeed(playerid,true) > 60)
{
SendClientMessage(playerid,RED,"A bomb has been planted on your bus,DON'T SLOW DOWN BELOW 50mph OR YOU'LL be blwoed up");
}
if(GetPlayerSpeed(playerid,true) < 50)
{
SetVehicleHealth(vehicleid,0);
SendClientMessage(playerid,RED,"BYE BYE,mission acomplished,bus blowed up");
}
}
}
stock GetPlayerSpeed(playerid, bool:kmh = true)
{
new
Float:xx,
Float:yy,
Float:zz,
Float:pSpeed;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
}
else
{
GetPlayerVelocity(playerid,xx,yy,zz);
}
pSpeed = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
return kmh ? floatround((pSpeed * 195.12)) : floatround((pSpeed * 121.9));
}
So,maybe I'm understandin worng,but please copy this script,test it on your gamemode(please),and only if it's working post reply.