23.02.2011, 16:36
Hi, I found this useful so I thought I would share it with you.
If you are a beginner you won't know all these useful tips.
So on this small tutorial I am going to show you how to not have cars spamming your map when you teleport to the location.
Take a look at this command,
This will put the player in a Cheetah when the player types /blueberry. When the player types it again, the car he got when he teleported there the first time, will just be sat laying there.
So if the player types /blueberry 10 times, there will be 10 cars there (in my case a cheetah)
So to fix that we do this.
First we start off with the variables.
This variable detects if the player has already made a vehicle or not already.
Now for the new code.
A few ID to know.
The 415 found on this line here, is the ID of the car.
You can find the ID's here https://sampwiki.blast.hk/wiki/Category:Vehicle
Wasn't much of a tutorial.
Hope I helped.
If you are a beginner you won't know all these useful tips.
So on this small tutorial I am going to show you how to not have cars spamming your map when you teleport to the location.
Take a look at this command,
pawn Code:
if((strcmp("/blueberry", cmdtext, true) == 0) || (strcmp("/bb", cmdtext, true) == 0))
{
SendClientMessage(playerid, 0x00FFFFAA, "You've been teleported to Blueberry.");
new vehicleid = CreateVehicle(415,-12.69693,1481.717,12.75, 180.0, -1, -1, -1);
PutPlayerInVehicle(playerid,vehicleid, 0);
return 1;
}
So if the player types /blueberry 10 times, there will be 10 cars there (in my case a cheetah)
So to fix that we do this.
First we start off with the variables.
This variable detects if the player has already made a vehicle or not already.
pawn Code:
//Put this varible near the top of your script, with all other variables - you can delete this green line after
new iSpawnedCar[MAX_PLAYERS] = -1;
pawn Code:
//Put this under OnPlayerCommandText - Delete this green line after.
if ((strcmp("/blueberry", cmdtext, true) == 0) || (strcmp("/bb", cmdtext, true) == 0))
{
if(iSpawnedCar[playerid] != -1) DestroyVehicle(iSpawnedCar[playerid]);
SendClientMessage(playerid, 0x00FFFFAA, "You've been teleported to Blueberry.");
iSpawnedCar[playerid] = CreateVehicle(415,-12.69693,1481.717,12.75, 180.0, -1, -1, -1);
PutPlayerInVehicle(playerid,iSpawnedCar[playerid], 0);
return 1;
}
The 415 found on this line here, is the ID of the car.
You can find the ID's here https://sampwiki.blast.hk/wiki/Category:Vehicle
pawn Code:
iSpawnedCar[playerid] = CreateVehicle(415,-12.69693,1481.717,12.75, 180.0, -1, -1, -1);
Hope I helped.