20.11.2011, 16:55
pawn Код:
#include <a_samp>
new Text3D:DonoVeiculo[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[50],idx, tmp[100];
cmd = strtok(cmdtext, idx);
if(strcmp(cmdtext,"/c", true) == 0 || strcmp(cmdtext,"/carro", true) == 0)
{
if(GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, COR_VERMELHO,"[ERRO]: Vocк nгo Pode Criar Veнculos em Interiores");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COR_VERMELHO,"[ERRO]: Vocк Jб Possui um Veнculo.");
new string[128];
new Float: X, Float: Y, Float: Z, Float: Angle;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
VeiculoID[playerid] = GetPlayerVehicleID(playerid); //
DestroyVehicle(VeiculoID[playerid]); //
DestroyVehicle(GetPVarInt(playerid,"Veiculo"));
PutPlayerInVehicle(playerid,CreateVehicle(411,X,Y, Z+2,Angle,-1,-1,-1),0);
new car = GetPlayerVehicleID(playerid);
AddVehicleComponent(car,1079);
SetPVarInt(playerid,"Veiculo",GetPlayerVehicleID(playerid));
format(string,sizeof(string),"Veiculo De:\n%s[ID:%d]", PlayerName(playerid), playerid);
DonoVeiculo[playerid] = Create3DTextLabel(string,0xFF8000FF,0,0,0,40.0,1);
Attach3DTextLabelToVehicle(DonoVeiculo[playerid], car, 0.0, 0.0, 1.0);
return 1;
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new str[50];
if (newstate == 2 || newstate == 3)
{
format(str, sizeof(str), "~g~%s",Veiculos[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
GameTextForPlayer(playerid, str, 3000, 1);
}
if(newstate == PLAYER_STATE_DRIVER)
{
if(strcmp(VeiculoID[GetPlayerVehicleID(playerid)], PlayerName(playerid), true) == 0)
Update3DTextLabelText(DonoVeiculo[playerid], 0xFF8000FF, " ");
}
if(oldstate == PLAYER_STATE_DRIVER)
{
if(strcmp(VeiculoID[GetPlayerVehicleID(playerid)], PlayerName(playerid), true) == 0)
{
new string[50];
format(string, sizeof(string), "Veiculo De:\n%s[ID:%d]", PlayerName(playerid), playerid);
Update3DTextLabelText(DonoVeiculo[playerid], 0xFF8000FF, string);
}
}
return 1;
}