give gun to a player
#1

The command
Код:
CMD:spray(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2 || PlayerInfo[playerid][pFaction] != 5) return SCM(playerid, COLOR_LIGHTRED, "Nu esti mechanic.");
    if(IsPlayerInRangeOfPoint(playerid, 20.0, 2180.9875,-1979.7583,13.5606)) //Optional - CHANGE
	{
		new string[128], sendername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], pID;
	 	GetPlayerName(playerid, sendername, sizeof(sendername));
		GetPlayerName(pID, targetname, sizeof(targetname));
		if(sscanf(params, "uii", pID, pick, color)) return SendClientMessage(playerid, -1, "[FOLOSIRE] /spray [ID/Name][Culoare 1/2][culoare]");
		if(pick > 2 || pick < 1) return SendClientMessage(playerid, COLOR_RED,"Colorpick can't be lower than 1 and higher than 2.");
		if(color > 126 || color < 0) return SendClientMessage(playerid, COLOR_RED,"Color ID can't be lower than 0 and higher than 126.");
		vehid = GetPlayerVehicleID(pID);
		format(string, sizeof(string), "%s vrea sa-ti vopseasca vehiculul. Slot Culoare: {FFFFFF}%d{468CFF}, ID Culoare: {FFFFFF}%d", PlayerName(playerid), pick, color);
		SendClientMessage(pID, COLOR_LIGHTBLUE, string);
		SendClientMessage(pID, COLOR_LIGHTBLUE, "Foloseste /acceptmeh pentru a accepta.");
		Service[pID][0] = 1;
	}
	else return SendClientMessage(playerid, COLOR_RED, "Trebuie sa fii in garaj pentru a repara!");
	return 1;
}
The other command, just Service[playerid][0] == 1 is for spray others are for repair
Код:
CMD:acceptmeh(playerid, params[])
{
    new Float: X, Float: Y, Float: Z, pID;
	if(Service[playerid][0] == 1)
	{
		SendClientMessage(playerid, -1, "Ai acceptat serviciul, te rugam asteapta!");
		GetVehiclePos(vehid, X, Y, Z);
		Car[1] = X;
		Car[2] = Y;
		Car[3] = Z;
		Spray[pID] = 1;
		GivePlayerWeapon(pID, 41, 500);
	}
	else if(Service[playerid][1] == 1)
	{
	    new panels,doors,lights,tires;
	   	SendClientMessage(playerid, COLOR_LIGHTBLUE, "Ai acceptat serviciul, te rugam asteapta!");
		vehid = GetPlayerVehicleID(playerid);
		tires = encode_tires(0, 0, 0, 0); // fix all tires
	    panels = encode_panels(0, 0, 0, 0, 0, 0, 0); // fix all panels
	    doors = encode_doors(0, 0, 0, 0, 0, 0); // fix all doors
	    lights = encode_lights(0, 0, 0, 0); // fix all lights
		UpdateVehicleDamageStatus(vehid, panels, doors, lights, tires);
		Service[playerid][1] = 0;
		SendClientMessage(playerid, COLOR_GREEN, "Caroseria vehiculului a fost reparata!");
	}
	else if(Service[playerid][2] == 1)
	{
	    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Ai acceptat serviciul, te rugam asteapta!");
		vehid = GetPlayerVehicleID(playerid);
		SetVehicleHealth(vehid, 1000.0);
		Service[playerid][2] = 0;
		SendClientMessage(playerid, COLOR_GREEN, "Motorul vehiculului a fost reparat!");
	}
	else return SendClientMessage(playerid, COLOR_RED, "Nu ti-a oferit nimeni sa-ti repare masina!");
	return 1;
}
The timer
Код:
forward OnPlayerSpray(playerid);
public OnPlayerSpray(playerid)
{
    if(pick == 1)
	{
    	ChangeVehicleColor(vehid, color, 0);
    	VehicleColor[playerid][0] = color;
	}
	else
	{   //new pID;
	    //new color2 = strval(inputtext);
		ChangeVehicleColor(vehid, 0, color);
		VehicleColor[playerid][1] = color;
		KillTimer(SprayT);
		Spray[playerid] = 0;
		Service[playerid][0] = 0;
		SaveVehicle(playerid);
		SendClientMessage(playerid, COLOR_GREEN, "Ai vopsit masina cu succes!");
	}
	return 1;
}
the timer
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 3.0, Car[1], Car[2], Car[3]))
	    {
		    if(Spray[playerid] == 1)
		    {
	    		SprayT = SetTimer("OnPlayerSpray", 5000, false);
		    }
		}
	}
	else return KillTimer(SprayT);
	return 1;
}
So if I use /spray on someone everything works fine, I get the can and spray the vehicle but if someone use the command on me and I /acceptmeh I will get the can, not them, also if they acceptmeh without any command I will still get a spray can..

I want that the guy who /spray me will get the can and the Spray[pID] = 1;, not me
Reply


Messages In This Thread
give gun to a player - by AndreiWow - 21.12.2015, 10:44
Re: give gun to a player - by Mic_H - 21.12.2015, 12:56
Re: give gun to a player - by AndreiWow - 21.12.2015, 19:10

Forum Jump:


Users browsing this thread: 1 Guest(s)