Ejecting a player if he dosent own
#1

Okay, I need help with this one. I have a mysql script and am running some cars of it and some static cars not off it. So far I've managed to allow player to access the unlocked AddStaticVehicle cars in the script. But now if a vehicle if for sale it ejects the person before they can /buyvehicle it and also it ejects a player from his own vehicle. Heres what I have so far:

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
		new string[128];
		new vehicle = GetPlayerVehicleID(playerid);
		new vid;
		if(vehicle >= 44)
		{
			if(vInfo[vid][vOwnerId] != PlayerInfo[playerid][pSQLId])
  			{
				SendClientMessage(playerid, COLOR_RED, "This Isent Your Vehicle");
				RemovePlayerFromVehicle(playerid);
			}
	  		if(vInfo[vehicle][vBuyAble] == 1)
			{
	  			format(string,sizeof(string),"This vehicle is for sale, you can buy it for %d$ (/buyvehicle)",vInfo[vehicle][vPrice]);
	    		SendClientMessage(playerid,0x33CCFFFF,string);
	  		}
	  		else if(vInfo[vehicle][vBuyAble] == 2 && PlayerInfo[playerid][pSQLId] == vInfo[vehicle][vOwnerId])
	  		{
	    		SendClientMessage(playerid,0x33CCFFFF,"Welcome to your vehicle.");
	  		}
		}
	}
	return 1;
}
I think vInfo[vid][vBuyAble]=2 defines if the vehicle is buyable...

any help is much appricated
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new string[128];
        new vehicle = GetPlayerVehicleID(playerid);
        new vid;
        if(vehicle >= 44)
        {
            if(vInfo[vehicle][vBuyAble] == 1)
            {
                format(string,sizeof(string),"This vehicle is for sale, you can buy it for %d$ (/buyvehicle)",vInfo[vehicle][vPrice]);
                SendClientMessage(playerid,0x33CCFFFF,string);
            }
            else if(vInfo[vehicle][vBuyAble] == 2)
            {
                if(vInfo[vid][vOwnerId] != PlayerInfo[playerid][pSQLId])
                {
                    SendClientMessage(playerid, COLOR_RED, "This Isn't Your Vehicle");
                    RemovePlayerFromVehicle(playerid);
                } else {           
                    SendClientMessage(playerid,0x33CCFFFF,"Welcome to your vehicle.");
                }
            }
        }
    }
    return 1;
}
Since its your code (and not the whole script), I have no idea if this is perfect, but I think this is what you want to do. By the way, nothing in this snippet is particularly unique to 3.0, this probably should be under Scripting Discussion. Second, use [ pawn ] tags instead of [ code ] tags when posting pawn code.
Reply
#3

Yea sorry about that :P

That now ejects a player from his own vehicle
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)