Custom vehicle spawnposition change
#1

Hey people, so basicly what I got now is when I /customvehicle blabla it goes to the given coordinates. How do I make it like it goes to the current position of the player you are making the /customvehicle for? Please help it.

Current code:
Код:
CMD:customvehicle(playerid, params[])
{
	new playerb, string[128], modelid, slot;
	if(sscanf(params, "udd", playerb, slot, modelid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /customvehicle [playerid] [1-3] [modelid]");
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(modelid < 400 || modelid > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");
   	if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(slot == 1)
	{
		PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, 532.3726,-1287.4926,17.2422,272.3125,0,0,32000);
	 	SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);
	 	PlayerInfo[playerb][vLocked] = 1;
	 	PlayerInfo[playerb][vModel] = modelid;
		GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
		GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);
		PlayerInfo[playerb][vC1] = 0;
		PlayerInfo[playerb][vC2] = 0;
		format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 1) %s.", NORPN(playerid), NORPN(playerb));
		SendAdminMessage(COLOR_DARKRED, 1, string);
	}
	else if(slot == 2)
	{
	        PlayerInfo[playerb][pVVeh] = CreateVehicle(modelid, 532.3726,-1287.4926,17.2422,272.3125,0,0,32000);
		    SetVehicleParamsEx(PlayerInfo[playerb][pVVeh], 0, 0, 0, 1, 0, 0, 0);
		    PlayerInfo[playerb][vVLocked] = 1;
		    PlayerInfo[playerb][vVModel] = modelid;
			GetVehiclePos(PlayerInfo[playerb][pVVeh], PlayerInfo[playerb][vVX], PlayerInfo[playerb][vVY], PlayerInfo[playerb][vVZ]);
			GetVehicleZAngle(PlayerInfo[playerb][pVVeh], PlayerInfo[playerb][vVA]);
			PlayerInfo[playerb][vVC1] = 0;
			PlayerInfo[playerb][vVC2] = 0;
			format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle (Slot 2) for %s.", NORPN(playerid), NORPN(playerb));
			SendAdminMessage(COLOR_DARKRED, 1, string);
	}
	else if(slot == 3)
	{
	 		PlayerInfo[playerb][pBVeh] = CreateVehicle(modelid, 532.3726,-1287.4926,17.2422,272.3125,0,0,32000);
	    	SetVehicleParamsEx(PlayerInfo[playerb][pBVeh], 0, 0, 0, 1, 0, 0, 0);
	    	PlayerInfo[playerb][vBLocked] = 1;
	    	PlayerInfo[playerb][vBModel] = modelid;
			GetVehiclePos(PlayerInfo[playerb][pBVeh], PlayerInfo[playerb][vBX], PlayerInfo[playerb][vBY], PlayerInfo[playerb][vBZ]);
			GetVehicleZAngle(PlayerInfo[playerb][pBVeh], PlayerInfo[playerb][vBA]);
			PlayerInfo[playerb][vBC1] = 0;
			PlayerInfo[playerb][vBC2] = 0;
			format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle (Slot 3) for %s.", NORPN(playerid), NORPN(playerb));
			SendAdminMessage(COLOR_DARKRED, 1, string);
Reply
#2

@Songason,

the same here.

oh wait, were on the same server -,-



Cheaaa' bro
Reply
#3

This should work, oh-yeah I also edited some of it, to make the indentation looks better (My Style of scripting)

pawn Код:
CMD:customvehicle(playerid, params[])
{
    new playerb, string[128], modelid, slot, Positions[3];

    if(sscanf(params, "udd", playerb, slot, modelid))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /customvehicle [playerid] [1-3] [modelid]");

    if(!IsPlayerLoggedIn(playerid))
        return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");

    if(<= 400 modelid <= 611)
        return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");

    if(PlayerInfo[playerid][pAdmin] < 3)
        return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    switch(slot)
    {
        GetPlayerPos(playerb, Positions[0], Positions[1], Positions[2]);
        case 1:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 1) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
        case 2:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 2) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
        case 3:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 3) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
    }
    return true;
}
Reply
#4

I get this error now with your code:

Код:
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : error 029: invalid expression, assumed zero
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : warning 215: expression has no effect
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : error 001: expected token: ";", but found "-identifier-"
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : warning 215: expression has no effect
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : error 001: expected token: ";", but found ")"
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : fatal error 107: too many error messages on one line
Reply
#5

Quote:
Originally Posted by Songason
Посмотреть сообщение
I get this error now with your code:

Код:
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : error 029: invalid expression, assumed zero
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : warning 215: expression has no effect
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : error 001: expected token: ";", but found "-identifier-"
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : warning 215: expression has no effect
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : error 001: expected token: ";", but found ")"
C:\Users\Sonny\Documents\scripting suite\ML-RP\gamemodes\modernliferp.pwn(9315) : fatal error 107: too many error messages on one line

What line is it? I probably miss something


What line is it? I probably missed something.
Reply
#6

Quote:
Originally Posted by pds2k12
Посмотреть сообщение

What line is it? I probably miss something


What line is it? I probably missed something.
This line:

Код:
    if(<= 400 modelid <= 611)
Reply
#7

Quote:
Originally Posted by Songason
Посмотреть сообщение
This line:

Код:
    if(<= 400 modelid <= 611)
Silly me!, This would compile properly, enjoy :P

pawn Код:
if(400 <= modelid <= 611)
Код:
This forum requires that you wait 240 seconds between posts. Please try again in 19 seconds. - you annoying little bitch.
Reply
#8

thnxxxx
Reply
#9

Alright, I did alot of mistake there due to I was in a hurry :P

Full Fix Code
pawn Код:
CMD:customvehicle(playerid, params[])
{
    new playerb, string[128], modelid, slot, Positions[3];

    if(sscanf(params, "udd", playerb, slot, modelid))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /customvehicle [playerid] [1-3] [modelid]");

    GetPlayerPos(playerb, Positions[0], Positions[1], Positions[2]);

    if(!IsPlayerLoggedIn(playerid))
        return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");

    if(400 <= modelid <= 611)
        return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");

    if(PlayerInfo[playerid][pAdmin] < 3)
        return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    switch(slot)
    {
        case 1:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 1) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
        case 2:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 2) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
        case 3:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 3) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
    }
    return true;
}
Reply
#10

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Silly me!, This would compile properly, enjoy :P

pawn Код:
if(400 <= modelid <= 611)
Код:
This forum requires that you wait 240 seconds between posts. Please try again in 19 seconds. - you annoying little bitch.
Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Alright, I did alot of mistake there due to I was in a hurry :P

Full Fix Code
pawn Код:
CMD:customvehicle(playerid, params[])
{
    new playerb, string[128], modelid, slot, Positions[3];

    if(sscanf(params, "udd", playerb, slot, modelid))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /customvehicle [playerid] [1-3] [modelid]");

    GetPlayerPos(playerb, Positions[0], Positions[1], Positions[2]);

    if(!IsPlayerLoggedIn(playerid))
        return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");

    if(400 <= modelid <= 611)
        return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");

    if(PlayerInfo[playerid][pAdmin] < 3)
        return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    switch(slot)
    {
        case 1:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 1) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
        case 2:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 2) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
        case 3:
        {
            PlayerInfo[playerb][pVeh] = CreateVehicle(modelid, Positions[0], Positions[1], Positions[2], 0, 0, 32000);

            GetVehiclePos(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vX], PlayerInfo[playerb][vY], PlayerInfo[playerb][vZ]);
            GetVehicleZAngle(PlayerInfo[playerb][pVeh], PlayerInfo[playerb][vA]);

            PlayerInfo[playerb][vC1] = 0, PlayerInfo[playerb][vC2] = 0,
            PlayerInfo[playerb][vLocked] = 1, PlayerInfo[playerb][vModel] = modelid;
            SetVehicleParamsEx(PlayerInfo[playerb][pVeh], 0, 0, 0, 1, 0, 0, 0);

            format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created a custom vehicle for (Slot 3) %s.", NORPN(playerid), NORPN(playerb)),
            SendAdminMessage(COLOR_DARKRED, 1, string);
        }
    }
    return true;
}
Compiled, no errors.

Altough it doesn't work, it says (also by proper vehicle ids for exemple turismo (451) ):

Vehicles are between 400 and 611.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)