14.01.2011, 18:08
i need the code where when you type /nrg it puts you straight into the vehicle or just the putplayerinvehicle thingy
thx
thx
pawn Код:
pawn Код:
|
if(!strcmp(cmdtext, "/nrg", true))
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "You can't use this command in a vehicle!");
new Float:X, Float:Y, Float:Z;
new NRG = CreateVehicle(522, X, Y, Z, 0.0000, -1, -1, 60000);
PutPlayerInVehicle(playerid, NRG, 0);
SendClientMessage(playerid, 0xFFFF00FF, "Enjoy your NRG!");
return 1;
}
Well in your code California, you don't store any position in those floats, therefore the vehicle won't be created at the players position, it'll be created at 0.0 0.0 0.0!
It'll also mean that the player can spam '/nrg' and make as many NRG's as he wants, which probably isn't a good power to give to the player. |
new bool:HasPlayerNRG[MAX_PLAYERS]; if (strcmp(cmdtext, "/nrg", true) == 0) { if(HasPlayerNRG[playerid]) { return SendClientMessage(playerid, YOURCOLOR, "* You already spawned a NRG!"); } new Float:X, Float:Y, Float:Z, Float:Ang; GetPlayerPos(playerid, X, Y, Z); GetPlayerFacingAngle(playerid, Ang); new Veh = CreateVehicle(522, X, Y, Z, Ang, -1, -1, -1); PutPlayerInVehicle(playerid, Veh, 0); HasPlayerNRG[playerid] = true; SendClientMessage(playerid, YOURCOLOR, "* You successfully spawned a NRG!"); return 1; }
I'm pretty sure you copied and pasted that code, as I saw it millions of times. You don't need to set the Angle, since it's not really important, and why are you using a player variable anyways? That's not needed, however, you have two codes to choose from. Not trying to be offensive and hi-jacking your script, but hey, you beat me, and this has way better readable code/indentation.
pawn Код:
|
#include <a_samp>
if(!strcmp(cmdtext, "/nrg", true))
{
new vehicleid = GetPlayerVehicleID(playerid), nrg;
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, " You can't use this command in a vehicle !");
if(GetVehicleModel(vehicleid) == 522 || GetPlayerVehicleSeat(playerid) == 0) return SendClientMessage(playerid, 0xAFAFAFAA, " You already have a NRG !");
new Float:X, Float:Y, Float:Z, Float:Angle;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
nrg = CreateVehicle(522, X, Y, Z, Angle, -1, -1, 60000);
PutPlayerInVehicle(playerid, nrg, 0);
SendClientMessage(playerid, 0xFFFF00FF, "Thank you for spawning a NRG, enjoy!");
return 1;
}