#1

i need the code where when you type /nrg it puts you straight into the vehicle or just the putplayerinvehicle thingy

thx
Reply
#2

Quote:
Originally Posted by [MTZ]H34DSh07z
Посмотреть сообщение
pawn Код:
new nrg[MAX_PLAYERS]//top of ongamemodeinit
pawn Код:
if (strcmp(cmdtext,"/nrg", true) == 0)
    {
       new Float:X, Float:Y, Float:Z, Float:Angle;
       GetPlayerPos(playerid,X,Y,Z);
       DestroyVehicle(nrg[playerid]);
       nrg[playerid] = CreateVehicle(522,X,Y,Z,Angle,-1,147,147);
       PutPlayerInVehicle(playerid,nrg[playerid],0);
       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 Код:
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;
}
Reply
#3

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.
Reply
#4

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
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.
yeah i dont want them to type /nrg and they can sit at the spawn and spam it i want them 2 type it and it puts them into a nrg and if their in a vehicle they cant spawn 1



thanks D:
Reply
#5

This should work

Код:
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;
}
Obviously, if you want to handle the vehicle, you should modify the variable before "CreateVehicle()".
Reply
#6

nonoon i want like when u type /nrg it puts u in a nrg at ur postion basicly
Reply
#7

Quote:
Originally Posted by California
Посмотреть сообщение
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 Код:
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 that code makes random unused variables.
a) The Global NRG Variable
b) The new NRG line.
I suggest using the global NRG Variable and then using that variable to remove the vehicle right after the player exits it (we don't want vehicle spam) How ever looking at that code, Not even its most likely to be Copy & Pasted, then it is a Crappy system.
Reply
#8

any1? can u just write the code for when u type /nrg it puts u in a nrg at ur postion basicly
Reply
#9

bump tryed them all and got errors can any1 just write me the simple code where when you type /nrg it puts u in a nrg at ur positon i had it on my old server i made a menu and when u picked a car it put you into that car
Reply
#10

Kase, you don't need brackets if your returning. You can just directly return it. But sorry for the confusion, this might work, maybe?

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)