help? -
xbox360boy66 - 18.08.2011
how would i set a cmd so if i said /nrg id get on a NRG bike..?
is it sommin alon the lines of
Код:
dcmd_abike(playerid,params[])
{
#pragma unused params
if(AccInfo[playerid][Level] >= 2)
{
if (!IsPlayerInAnyVehicle(playerid))
{
CarSpawner(playerid,522);
SendCommandToAdmins(playerid,"ABike");
return SendClientMessage(playerid,yellow,"|- Bike Successfully Created! -|");
}
else return SendClientMessage(playerid,red,"Error: You already have a vehicle");
}
else return ErrorMessages(playerid, 7);
}
Re: help? -
Riddick94 - 18.08.2011
You wan't to be in this vehicle automaticly?
https://sampwiki.blast.hk/wiki/Function:PutPlayerInVehicle
Re: help? -
xbox360boy66 - 18.08.2011
Quote:
Originally Posted by Riddick94
|
yes, yes i do.
Re: help? -
xbox360boy66 - 18.08.2011
would this work?
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/nrg", cmdtext, true, 10) == 0)
{
PutPlayerInVehicle(playerid, vehicleid, 0);
return 1;
}
return 0;
}
Re: help? -
Riddick94 - 18.08.2011
No. Save vehicle to variable:
pawn Код:
variable = CreateVehicle([...]);
and then use function but with variable parameter, no vehicleid.
pawn Код:
PutPlayerInVehicle(playerid, variable, 0);
Of course you can name your variable how you wan't. Vehicle, vehicleid, nrg and other. But function need to know to what vehicle you wan't put player.
Re: help? -
xbox360boy66 - 18.08.2011
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/nrg", cmdtext, true, 10) == 0)
{
variable = CreateVehicle([481]);
PutPlayerInVehicle(playerid, variable, 0);
return 1;
}
return 0;
}
Like that?? Im really new to this so i expect it will be wrong xD
Re: help? -
Riddick94 - 18.08.2011
Okey so listen me now.
[...] - this mean other values for CreateVehicle function. Values for this function you can find here:
https://sampwiki.blast.hk/wiki/CreateVehicle
to create variable you need to do this:
And then just in command set it just like you made it. But you need to put values into CreateVehicle.
pawn Код:
new variable;
variable = CreateVehicle(values function);
PutPlayerInVehicle(playerid, variable, 0);
Re: help? -
xbox360boy66 - 18.08.2011
Ok i think thats a pretty basic cmd? But i think i have managed to mess it up once agian..
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/nrg", cmdtext, true, 10) == 0)
{
new variable;
variable = CreateVehicle(481, 0.0, 0.0, 0.0, 2, 4, 0 );
PutPlayerInVehicle(playerid, variable, 0);
return 1;
}
return 0;
}
Re: help? -
Riddick94 - 18.08.2011
Код:
(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
Your model id is 481 - okey.
X, Y, Z - position where to create NRG.
Angle - rotation of the bike.
color1, color2 - colours of the vehicle.
respawn_delay - in what time vehicle will respawn after player exit it.
We need to get player position X, Y, Z and (optional) angle.
You need to create variables wich will save float.
pawn Код:
new Float:X, Float:Y, Float:Z, Float:Angle;
then use a function
https://sampwiki.blast.hk/wiki/Function:GetPlayerPos to get X, Y, Z and
https://sampwiki.blast.hk/wiki/GetPlayerFacingAngle to get player rotation (remember it's optional)
Then after you get position and rotation of player put variables X, Y, Z, Angle into values of CreateVehicle.
Re: help? -
xbox360boy66 - 18.08.2011
urrm ya know what. Thats to complicated for me xD.
im gonna go download one that some has done already..
Re: help? -
Riddick94 - 18.08.2011
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/nrg", cmdtext, true, 10) == 0)
{
new variable;
new Float:X, Float:Y, Float:Z, Float:Angle;
variable = CreateVehicle(481, X, Y, Z, Angle, 2, 4, -1); // -1 will never respawn.
PutPlayerInVehicle(playerid, variable, 0);
return 1;
}
return 0;
}
Am.. it's not complicated..
Re: help? -
xbox360boy66 - 18.08.2011
Quote:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/nrg", cmdtext, true, 10) == 0)
{
new variable;
new Float:X, Float:Y, Float:Z, Float:Angle;
variable = CreateVehicle(481, X, Y, Z, Angle, 2, 4, -1); // -1 will never respawn.
PutPlayerInVehicle(playerid, variable, 0);
return 1;
}
return 0;
}
|
Cheers. God you make me feel so retarded xD
Re: help? -
xbox360boy66 - 18.08.2011
Quote:
Originally Posted by Riddick94
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp("/nrg", cmdtext, true, 10) == 0) { new variable; new Float:X, Float:Y, Float:Z, Float:Angle; variable = CreateVehicle(481, X, Y, Z, Angle, 2, 4, -1); // -1 will never respawn. PutPlayerInVehicle(playerid, variable, 0); return 1; } return 0; }
Am.. it's not complicated..
|
When i do it. it sends me under the map then to a random farm and if i keep doing it i can make a tall tower of NRGs, BMX... ?
Re: help? -
Riddick94 - 18.08.2011
Add to CreateVehicle Z value this:
change just.
Re: help? -
xbox360boy66 - 18.08.2011
Код HTML:
if (strcmp("/nrg", cmdtext, true, 10) == 0)
{
new variable;
new Float:X, Float:Y, Float:Z, Float:Angle;
variable = CreateVehicle(522, X, Y, Z, Angle, 2, 4, Z+2.0); // -1 will never respawn.
PutPlayerInVehicle(playerid, variable, 0);
return 1;
Like that?
Re: help? -
Riddick94 - 18.08.2011
No. I said change Z this what you have now.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/nrg", cmdtext, true, 10) == 0)
{
new variable;
new Float:X, Float:Y, Float:Z, Float:Angle;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
variable = CreateVehicle(481, X, Y, Z, Angle, 2, 4, -1); // -1 will never respawn.
PutPlayerInVehicle(playerid, variable, 0);
return 1;
}
return 0;
}
EPIC MY FAIL. I didn't add earlier GetPlayerPos and GetPlayerFacingAngle. This will now work for sure.
Re: help? -
doreto - 18.08.2011
^^ i hope
Re: help? -
xbox360boy66 - 18.08.2011
Quote:
Originally Posted by Riddick94
No. I said change Z this what you have now.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp("/nrg", cmdtext, true, 10) == 0) { new variable; new Float:X, Float:Y, Float:Z, Float:Angle; GetPlayerPos(playerid, X, Y, Z); GetPlayerFacingAngle(playerid, Angle); variable = CreateVehicle(481, X, Y, Z, Angle, 2, 4, -1); // -1 will never respawn. PutPlayerInVehicle(playerid, variable, 0); return 1; } return 0; }
EPIC MY FAIL. I didn't add earlier GetPlayerPos and GetPlayerFacingAngle. This will now work for sure.
|
Cheers, works perfectly.