[HELP] Carspawn command -
WThieves - 06.07.2010
I need help, i've been looking all over the place to find a carspawn script, i need one that spawns a car for you (where you are) and if you spawn a new car the old one gets deleted and respawned or warped to you, also when you log off the old one dissapears, have tried it myself but couldnt make it work, (the farthest i have come is spawning a car but you steal someone elses XD)
So please help me locate this.
Thanks in advance!
Re: [HELP] Carspawn command -
CAR - 06.07.2010
Top:
pawn Код:
new PlayerVehicle[MAX_PLAYERS];
Connect:
pawn Код:
public OnPlayerConnect(playerid)
{
PlayerVehicle[playerid] = 0;
return 1;
}
Disconnect:
pawn Код:
public OnPlayerDisconnect(playerid)
{
if(PlayerVehicle[playerid] != 0) { DestroyVehicle(PlayerVehicle[playerid]); }
return 1;
}
Command:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], tmp[256], tmp2[256], tmp3[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/v", true) == 0)
{
tmp = strtok(cmdtext, idx); tmp2 = strtok(cmdtext, idx); tmp3 = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, rood, "USAGE: /v [Modelid/Name] [colour1] [colour2]");
new car, colour1, colour2;
car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid, rood, "ERROR: Invalid Vehicle Model");
if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
new Float:X,Float:Y,Float:Z, Float:Angle,int1;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
int1 = GetPlayerInterior(playerid);
if(PlayerVehicle[playerid] != 0) { DestroyVehicle(PlayerVehicle[playerid]); }
PlayerVehicle[playerid] = CreateVehicle(car, X+3,Y,Z, Angle, colour1, colour2, 99999);
LinkVehicleToInterior(PlayerVehicle[playerid],int1);
PutPlayerInVehicle(playerid, PlayerVehicle[playerid], 0);
return 1;
}
return 0;
}
I think this will work
Re: [HELP] Carspawn command -
TheGarfield - 06.07.2010
pawn Код:
if(strcmp(cmdtext, "/RespawnVehicle", true) )
{
VehicleReset();
return 1;
}
forward VehicleReset();
public VehicleReset()
{
new string[128];
format(string, sizeof(string), "Os Veнculos forгo Respawnados Automaticamente");
SendClientMessageToAll(Aviso, string);
new inVeh;
for( new i = 0; i < MAX_VEHICLES; i++ )
{
inVeh = false;
for( new j = 0; j < MAX_PLAYERS; j++ )
{
if(IsPlayerInVehicle( j, i ))
{
inVeh = true;
break;
}
}
if(!inVeh)
{
SetVehicleToRespawn(i);
}
}
}
Re: [HELP] Carspawn command -
WThieves - 06.07.2010
Quote:
Originally Posted by CAR
Top:
pawn Код:
new PlayerVehicle[MAX_PLAYERS];
Connect:
pawn Код:
public OnPlayerConnect(playerid) { PlayerVehicle[playerid] = 0; return 1; }
Disconnect:
pawn Код:
public OnPlayerDisconnect(playerid) { if(PlayerVehicle[playerid] != 0) { DestroyVehicle(PlayerVehicle[playerid]); } return 1; }
Command:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256], tmp[256], tmp2[256], tmp3[256], idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/v", true) == 0) { tmp = strtok(cmdtext, idx); tmp2 = strtok(cmdtext, idx); tmp3 = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, rood, "USAGE: /v [Modelid/Name] [colour1] [colour2]"); new car, colour1, colour2; car = strval(tmp); if(car < 400 || car > 611) return SendClientMessage(playerid, rood, "ERROR: Invalid Vehicle Model"); if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2); if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3); new Float:X,Float:Y,Float:Z, Float:Angle,int1; GetPlayerPos(playerid, X,Y,Z); GetPlayerFacingAngle(playerid,Angle); int1 = GetPlayerInterior(playerid); if(PlayerVehicle[playerid] != 0) { DestroyVehicle(PlayerVehicle[playerid]); } PlayerVehicle[playerid] = CreateVehicle(car, X+3,Y,Z, Angle, colour1, colour2, 99999); LinkVehicleToInterior(PlayerVehicle[playerid],int1); PutPlayerInVehicle(playerid, PlayerVehicle[playerid], 0); return 1; } return 0; }
I think this will work
|
That one is okay but i need a command that spawns one car only and if i spawn it again it deletes the old one and creates a new one.
Re: [HELP] Carspawn command -
CAR - 06.07.2010
If you spawn a new one now, the old one will be destroyed
Re: [HELP] Carspawn command -
TheKingOfSamp - 06.07.2010
Код HTML:
if(strcmp(cmd, "/veh", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
return 1;
}
new car;
car = strval(tmp);
if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, " Vehicle Number can't be below 400 or above 611 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
return 1;
}
new color1;
color1 = strval(tmp);
if(color1 < 0 || color1 > 252) { SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 126 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
return 1;
}
new color2;
color2 = strval(tmp);
if(color2 < 0 || color2 > 252) { SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 126 !"); return 1; }
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new carid = CreateVehicle(car, X+2,Y,Z, 0.0, color1, color2, 60000);
format(string, sizeof(string), " Vehicle %d spawned.", carid);
PutPlayerInVehicle(playerid, carid, 0);
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}
Re: [HELP] Carspawn command -
WThieves - 07.07.2010
Quote:
Originally Posted by CAR
If you spawn a new one now, the old one will be destroyed
|
Okay but how do i change this so it spawns (for example) an infernus if veh = 1 and an nrg if veh = 2 and if veh = 0 it says you don't have a car.
Thanks in advance
Re: [HELP] Carspawn command -
CAR - 07.07.2010
So you want to spawn 2 vehicles?
Re: [HELP] Carspawn command -
WThieves - 07.07.2010
Quote:
Originally Posted by CAR
So you want to spawn 2 vehicles?
|
No i want to spawn 1 vehicle, Ex, if i go to a menu and select NRG my [veh] is set to 1 and if i spawn the car it gives me a nrg (cause NRG is linked to 1) and if i select INF my [veh] is set to 2 and if is pawn a car it gives me an infernus (cause INF is linked to 2) and if i already spawned a vehicle (doesnt matter which 1 or 2) it gets deleted and the new one gets created, And if veh is set to 0 The command returns "You don't have a vehicle selected"
.
Re: [HELP] Carspawn command -
CAR - 07.07.2010
Lol that's really dificult, I don't got the time for that now :P