/v removes last spawned vehicle
#1

Hey guys!

I have a car spawner in my server, and I want to make it so that, wheneven a player spawns a new vehicle, the other one gets distroyed (de-spawned). Here's my current script: http://pastebin.com/cgjLsxMd

Any help would be greatly apriciated!

-Nick
Reply
#2

Instead of defining "car" variable for each menu item, define it globally that way:

pawn Код:
new car[MAX_PLAYERS];
then each time a vehicle is being spawned the current gets destroyed like that..

pawn Код:
DestroyVehicle(car[playerid]);
So it be finally like that..

pawn Код:
// Anywhere after the includes..
new car[MAX_PLAYERS];

// An example of responding to a menu-item..
case 0: //go kart
{
            new Float:x, Float:y, Float:z, Float:a;
            GetPlayerFacingAngle(playerid,a);
            GetPlayerPos(playerid, x, y, z);
            if(car[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(car[playerid]);
            car[playerid] = CreateVehicle(571,x,y,z+4,a,-1,-1,30000);
            PutPlayerInVehicle(playerid,car,0);
            SendClientMessage(playerid, 0xFFFFFFFF, "Je selecteerde een Go Kart");
 
}
Reply
#3

Quote:
Originally Posted by Randy More
Посмотреть сообщение
Instead of defining "car" variable for each menu item, define it globally that way:

pawn Код:
new car[MAX_PLAYERS];
then each time a vehicle is being spawned the current gets destroyed like that..

pawn Код:
DestroyVehicle(car[playerid]);
So it be finally like that..

pawn Код:
// Anywhere after the includes..
new car[MAX_PLAYERS];

// An example of responding to a menu-item..
case 0: //go kart
{
            new Float:x, Float:y, Float:z, Float:a;
            GetPlayerFacingAngle(playerid,a);
            GetPlayerPos(playerid, x, y, z);
            if(car[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(car[playerid]);
            car[playerid] = CreateVehicle(571,x,y,z+4,a,-1,-1,30000);
            PutPlayerInVehicle(playerid,car,0);
            SendClientMessage(playerid, 0xFFFFFFFF, "Je selecteerde een Go Kart");
 
}
Thanks! Going to edit my script!
Reply
#4

Quote:
Originally Posted by Randy More
Посмотреть сообщение
Instead of defining "car" variable for each menu item, define it globally that way:

pawn Код:
new car[MAX_PLAYERS];
then each time a vehicle is being spawned the current gets destroyed like that..

pawn Код:
DestroyVehicle(car[playerid]);
So it be finally like that..

pawn Код:
// Anywhere after the includes..
new car[MAX_PLAYERS];

// An example of responding to a menu-item..
case 0: //go kart
{
            new Float:x, Float:y, Float:z, Float:a;
            GetPlayerFacingAngle(playerid,a);
            GetPlayerPos(playerid, x, y, z);
            if(car[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(car[playerid]);
            car[playerid] = CreateVehicle(571,x,y,z+4,a,-1,-1,30000);
            PutPlayerInVehicle(playerid,car,0);
            SendClientMessage(playerid, 0xFFFFFFFF, "Je selecteerde een Go Kart");
 
}
Ok, so I edited my script (What it is now > http://pastebin.com/Rxd2qW6c)
And I get these errors:
Код:
autos.pwn(237) : error 033: array must be indexed (variable "car")
autos.pwn(238) : error 035: argument type mismatch (argument 2)
autos.pwn(249) : error 033: array must be indexed (variable "car")
autos.pwn(250) : error 035: argument type mismatch (argument 2)
autos.pwn(260) : error 033: array must be indexed (variable "car")
autos.pwn(261) : error 035: argument type mismatch (argument 2)
autos.pwn(271) : error 033: array must be indexed (variable "car")
autos.pwn(272) : error 035: argument type mismatch (argument 2)
autos.pwn(282) : error 033: array must be indexed (variable "car")
autos.pwn(283) : error 035: argument type mismatch (argument 2)
autos.pwn(293) : error 033: array must be indexed (variable "car")
autos.pwn(294) : error 035: argument type mismatch (argument 2)
autos.pwn(310) : error 033: array must be indexed (variable "car")
autos.pwn(311) : error 035: argument type mismatch (argument 2)
autos.pwn(321) : error 033: array must be indexed (variable "car")
autos.pwn(322) : error 035: argument type mismatch (argument 2)
autos.pwn(335) : error 033: array must be indexed (variable "car")
autos.pwn(336) : error 035: argument type mismatch (argument 2)
autos.pwn(349) : error 033: array must be indexed (variable "car")
autos.pwn(350) : error 035: argument type mismatch (argument 2)
autos.pwn(380) : error 033: array must be indexed (variable "car")
autos.pwn(381) : error 035: argument type mismatch (argument 2)
autos.pwn(391) : error 033: array must be indexed (variable "car")
autos.pwn(392) : error 035: argument type mismatch (argument 2)
autos.pwn(403) : error 033: array must be indexed (variable "car")
autos.pwn(404) : error 035: argument type mismatch (argument 2)
What's wrong?
Reply
#5

Bump
Reply
#6

Replace all "car=CreateVehicle(...)" to "car[playerid] = CreateVehicle(...)"
Reply
#7

Quote:
Originally Posted by Ataraxia
Посмотреть сообщение
Replace all "car=CreateVehicle(...)" to "car[playerid] = CreateVehicle(...)"
Did that, still getting the same errors
(Edited pwn link: http://pastebin.com/4YXy3aAN)

Код:
autos.pwn(238) : error 035: argument type mismatch (argument 2)
autos.pwn(250) : error 035: argument type mismatch (argument 2)
autos.pwn(261) : error 035: argument type mismatch (argument 2)
autos.pwn(272) : error 035: argument type mismatch (argument 2)
autos.pwn(283) : error 035: argument type mismatch (argument 2)
autos.pwn(294) : error 035: argument type mismatch (argument 2)
autos.pwn(311) : error 035: argument type mismatch (argument 2)
autos.pwn(322) : error 035: argument type mismatch (argument 2)
autos.pwn(336) : error 035: argument type mismatch (argument 2)
autos.pwn(350) : error 035: argument type mismatch (argument 2)
autos.pwn(381) : error 035: argument type mismatch (argument 2)
autos.pwn(392) : error 035: argument type mismatch (argument 2)
autos.pwn(404) : error 035: argument type mismatch (argument 2)
autos.pwn(415) : error 035: argument type mismatch (argument 2)
autos.pwn(426) : error 035: argument type mismatch (argument 2)
autos.pwn(437) : error 035: argument type mismatch (argument 2)
autos.pwn(449) : error 035: argument type mismatch (argument 2)
autos.pwn(464) : error 035: argument type mismatch (argument 2)
autos.pwn(488) : error 035: argument type mismatch (argument 2)
autos.pwn(499) : error 035: argument type mismatch (argument 2)
autos.pwn(510) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Reply
#8

PHP код:
PutPlayerInVehicle(playerid,car,0);
// To
PutPlayerInVehicle(playeridcar[playerid], 0); 
Reply
#9

Quote:
Originally Posted by Ataraxia
Посмотреть сообщение
PHP код:
PutPlayerInVehicle(playerid,car,0);
// To
PutPlayerInVehicle(playeridcar[playerid], 0); 
Thanks! That fixed it! Rep'd
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)