Vehicle Windows
#1

I made a simple window system, when you /car windows once you'll chat there will be [Windows Shut] or [Windows Down] but this what happens. + It's working too on Bikes which is not supposed to be.

New
Код:
new VehicleWindows[MAX_VEHICLES] = 0;
OnPlayerText
Код:
if(IsPlayerInAnyVehicle(playerid))
  	{
    	if(VehicleWindows[playerid] == 0)
    	{
       		format(string, sizeof(string), "%s says [Windows Shut]: %s", sendername, text);
			ProxDetector(20.0, playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    	}
    	else if(VehicleWindows[playerid] == 1)
    	{
    	    format(string, sizeof(string), "%s says [Windows Down]: %s", sendername, text);
			ProxDetector(20.0, playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    	}
  		return 1;
	}
Pictures here!
Reply
#2

You declared VehicleWindows for MAX_VEHICLES, so use a vehicleid, not playerid.

EDIT: Use GetPlayerVehicleID to get the vehicleid.
Reply
#3

Write it like this:

PHP код:
new bool:window[MAX_VEHICLES char];
public 
OnPlayerText(playeridtext[])
{
    new 
GetPlayerVehicleID(playerid);
    if(
&& !IsABike(v)) //So only if he is in a vehicle and its not a bike
    
{
        
format(stringsizeof(string), "%s says %s: %s"sendername, (!window{v})?("[Windows Shut]"):("[Windows Down]"),text);
        
ProxDetector(20.0playeridstringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
        return 
0;
    }
    return 
1;
}
//if you dont have it:
#define SCM SendClientMessage
//and in the window command:
new GetPlayerVehicleID(playerid);
if(!
v) return SCM(playerid,-1,"You are not in a vehicle!");
if(
IsABike(v)) return SCM(palyerid,-1,"A bike has no windows!");
window{v} = !window{v};
GameTextForPlayer(playerid,(!window{v})?("~r~Window closed"):("~g~Window opened"),5000,5);
return 
1;
//Then at the end of the script
stock IsABike(vid)
{
    new 
GetVehicleModel(vid);
    return (
== 509||==510||==581||==522||==521||==523||==586||==481||==462||==448||==461||==463||==468||==471);

Greekz
Reply
#4

Once I put the code to OnPlayerText my pawno stops working.
Код:
public OnPlayerText(playerid, text[])
{
    new v = GetPlayerVehicleID(playerid);
    if(v && !IsABike(v)) //So only if he is in a vehicle and its not a bike
    	{
        	format(string, sizeof(string), "%s says %s: %s", sendername, (!window{v})?("[Windows Shut]"):("[Windows Down]"),text);
        	ProxDetector(20.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
        	return 0;
    	}
    	return 1;
	}
	if(gPlayerLogged{playerid} != 1)
	{
		SendClientMessageEx(playerid, COLOR_RED, "You are not logged in.");
		return 0;
	}

	new sendername[MAX_PLAYER_NAME];
	new giveplayer[MAX_PLAYER_NAME];
	new string[128];
	playerLastTyped[playerid] = 0;

	if(TextSpamUnmute[playerid] != 0)
	{
		if(PlayerInfo[playerid][pAdmin] < 2)
		{
			//SendClientMessage(playerid, COLOR_WHITE, "You are muted from submitting text right now.");
			format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has been automatically kicked for command spamming.", GetPlayerNameEx(playerid), playerid);
			ABroadCast(COLOR_YELLOW, string, 2);
		
			ShowPlayerDialog(playerid, DIALOG_SHOW_INFO, DIALOG_STYLE_MSGBOX, "{FFFFFF}Kicked from server", "You have been kicked from the server for command spam.", "Ok", "Cancel");
			SetTimerEx("SendToKick", 300, 0, "i", playerid);
			return 0;
		}
	}

	if(PlayerInfo[playerid][pAdmin] < 2)
	{
		TextSpamTimes[playerid]++;

		if(TextSpamTimes[playerid] == 5)
		{
			TextSpamTimes[playerid] = 0;
			TextSpamUnmute[playerid] = 10;
			SendClientMessageEx(playerid, COLOR_YELLOW, "You have been muted automatically for spamming. Please wait 10 seconds and try again.");
			SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_FLOODPROTECTION);
			

			return 0;
		}
	}


 	/*Compares last string with current, if the same, alert the staff only on the 3rd command. (Expires after 5 secs)
	if(PlayerInfo[playerid][pAdmin] < 2) {
		new laststring[128];
		if(GetPVarString(playerid, "LastText", laststring, 128)) {
			if(!strcmp(laststring, text, true)) {
				TextSpamTimes[playerid]++;

				if(TextSpamTimes[playerid] == 2) {
					TextSpamTimer[playerid] = 30;
					TextSpamTimes[playerid] = 0;
					format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) is spamming with: %s", GetPlayerNameEx(playerid), playerid, text);
					ABroadCast(COLOR_YELLOW, string, 2);
				}
			}
		}
		SetPVarString(playerid, "LastText", text);
	}*/

	if(strfind(text, "|", true) != -1) {
	    SendClientMessageEx(playerid, COLOR_RED, "You cannot use the '|' character in text.");
		return 0;
	}
	if(PlayerInfo[playerid][pMuted] == 1)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You cannot speak, you have been silenced!");
		return 0;
	}
Reply
#5

Quote:
Originally Posted by lwilson
Посмотреть сообщение
Once I put the code to OnPlayerText my pawno stops working.
Yes because you made an bracket mistake, write it like this:

Код:
new v = GetPlayerVehicleID(playerid);
if(v && !IsABike(v)) //So only if he is in a vehicle and its not a bike
{
    format(string, sizeof(string), "%s says %s: %s", sendername, (!window{v})?("[Windows Shut]"):("[Windows Down]"),text);
    ProxDetector(20.0, playerid, string, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
    return 0;
}
if(gPlayerLogged{playerid} != 1)
{
    SendClientMessageEx(playerid, COLOR_RED, "You are not logged in.");
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)