SA-MP Forums Archive
Why wont this work for me? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why wont this work for me? (/showthread.php?tid=195692)



Why wont this work for me? - Fool - 03.12.2010

Im Having A issue, i tried to fix it but it Just wont Work
Here's The code
i Need this Very Much...

Код:
	if(PlayerInfo[playerid][IsCivil] == 1)
	if(vehicleid == 596 || vehicleid == 597 || vehicleid == 598)
	{
		new string[128];
		SetPlayerWantedLevel(playerid, 4);
		format(string,sizeof(string),"WARNING: Your wanted level has been increased to %d",GetPlayerWantedLevel(playerid));
		SendClientMessage(playerid,red,string);
	}
Please, i need this verymuch.


Re: Why wont this work for me? - WillyP - 03.12.2010

What doesn't work?


Re: Why wont this work for me? - Fool - 03.12.2010

It's should give a effect but it doesnt do anything, i Just enter the vehicle id, and It does nothing.
if u ask if im a civil, yes i am civil while i tried.


Re: Why wont this work for me? - blackwave - 03.12.2010

Код:
new id; id = GetPlayerVehicleID(playerid);
Before the if...


Re: Why wont this work for me? - Fool - 03.12.2010

Thanks. Finally.


Re: Why wont this work for me? - Fool - 03.12.2010

I think i fucked up again.

Код:
CR.pwn(11633) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
Do i have to return 1;
?


AW: Why wont this work for me? - Extremo - 03.12.2010

Add the callback you are using in the first post to clear misunderstanding and remove the entire line given by blackwave as it does not fix anything.

Fix your indentation a slight bit, even though it is valid to do something like
pawn Код:
if(condition)
  statement;
I still believe its better to do:
pawn Код:
if(condition)
{
    if(secondcondition)
In fact, your code would be much better this way:
pawn Код:
if(condition1 && condition2)
{



Re: Why wont this work for me? - Geso - 03.12.2010

ehm, right.

This would end up wrong anyways, so i'll correct it.

You probably want to check if they're in a police car right? Cause vehicleid doesnt correspond to the model of the car, vehicleid is the id that's assigned to the car.

If you want to check if they step in a police car, it would be like this:

Код:
	if(PlayerInfo[playerid][IsCivil] == 1)
	if(GetVehicleModel(vehicleid) == 596 || GetVehicleModel(vehicleid) == 597 || GetVehicleModel(vehicleid) == 598)
	{
		new string[128];
		SetPlayerWantedLevel(playerid, 4);
		format(string,sizeof(string),"WARNING: Your wanted level has been increased to %d",GetPlayerWantedLevel(playerid));
		SendClientMessage(playerid,red,string);
	}



Re: Why wont this work for me? - Fool - 03.12.2010

Quote:
Originally Posted by Geso
Посмотреть сообщение
ehm, right.

This would end up wrong anyways, so i'll correct it.

You probably want to check if they're in a police car right? Cause vehicleid doesnt correspond to the model of the car, vehicleid is the id that's assigned to the car.

If you want to check if they step in a police car, it would be like this:

Код:
	if(PlayerInfo[playerid][IsCivil] == 1)
	if(GetVehicleModel(vehicleid) == 596 || GetVehicleModel(vehicleid) == 597 || GetVehicleModel(vehicleid) == 598)
	{
		new string[128];
		SetPlayerWantedLevel(playerid, 4);
		format(string,sizeof(string),"WARNING: Your wanted level has been increased to %d",GetPlayerWantedLevel(playerid));
		SendClientMessage(playerid,red,string);
	}
Worked Prefect, No warings, no erros. Thank You Sir. or Cat... Lol.


Re: Why wont this work for me? - Geso - 03.12.2010

Quote:
Originally Posted by Porsche911
Посмотреть сообщение
Worked Prefect, No warings, no erros. Thank You Sir. or Cat... Lol.
No problem