new Float:X,Float:Y,Float:Z; // Criamos a vбriavel da cordenada estilo Float
new Float:A; // Criamos outra variavel float para salvar o angulo
GetPlayerPos(playerid, X, Y, Z); // Usamos as variaveis X, Y e Z para getar a posiзгo
GetPlayerFacingAngle(playerid,A); // Usamos a Variavel A para getar o angulo do player
AddStaticVehicleEx(424, X, Y, Z, A, 1, 1, 120); // Usamos as variбveis que getamos do player na criaзгo do carro
//variбveis
new Float:x, Float:y, Float:z, Float:a;
//pegar posiзгo e вngulo
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
GetXYInFrontOfPlayer(playerid, x, y, 5.0); //atribuir а X e Y as coordenadas da frente do jogador em 5 metros de distвncia
AddStaticVehicleEx(424, x, y, z, a, 1, 1, 120); //criar NRG
//funзгo para pegar a frente do jogador
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
// Created by ******
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) {
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
return 1;
}
|
Para criar a NRG na frente do jogador:
Код:
//variбveis
new Float:x, Float:y, Float:z, Float:a;
//pegar posiзгo e вngulo
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
GetXYInFrontOfPlayer(playerid, x, y, 5.0); //atribuir а X e Y as coordenadas da frente do jogador em 5 metros de distвncia
AddStaticVehicleEx(424, x, y, z, a, 1, 1, 120); //criar NRG
//funзгo para pegar a frente do jogador
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
// Created by ******
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) {
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
return 1;
}
|
|
rodrigo, pra mim nгo criar um tуpico, me explica uma coisa, pq as vezes as pessoas colocam return 0 e nгo return 1 em funзхes? qual a diferenзa?
e pra q serve variбveis staticas? ja li sobre elas mas n entendo bem o uso das mesmas, se puder me ajudar ![]() |
new var = FuncaoTeste(); //var vale 6
new var = Somar(2, 2); //var vale 4 | 2 + 2 = 4
new var = Somar2(3, 3); //var vale 6, pois essa funзгo retornou o retorno de outra funзгo
stock FuncaoTeste()
{
return 6;
}
stock Somar(numero1, numero2)
{
return numero1 + numero2;
}
stock Somar2(numero1, numero2)
{
return Somar(numero1, numero2);
}