29.06.2012, 20:50
im not a pro at this but ill highlight what you did wrong
EDIT FOUND IT...
EDIT2: This will spawn the player in the car if any errors tell me.
pawn Code:
command(changeplayercar, playerid, params[])
{
new id, carid, vehslot, string[128];
if(sscanf(params, "udd", id, carid, vehslot))
{
if(Player[playerid][AdminLevel] >= 5)
{
SendClientMessage(playerid, WHITE, "SYNTAX: /changeplayercar [playerid] [carid] [1-4]");
}
}
else
{
if(Player[playerid][AdminLevel] >= 5)
{
if(IsPlayerConnectedEx(id))
{
switch(vehslot)
{
case 1:
{
if(carid >= 400 && carid < 611)
{
if(Player[id][PlayerCarModel] >= 1)
{
if(Player[id][CarLinkID] >= 1)
{
DestroyVehicle(Player[id][CarLinkID]);
Player[id][CarLinkID] = 0;
OwnedCarCount--;
CarCount--;
}
Player[playerid][OwnedCarModSlot0] = 0;
Player[playerid][OwnedCarModSlot1] = 0;
Player[playerid][OwnedCarModSlot2] = 0;
Player[playerid][OwnedCarModSlot3] = 0;
Player[playerid][OwnedCarModSlot4] = 0;
Player[playerid][OwnedCarModSlot5] = 0;
Player[playerid][OwnedCarModSlot6] = 0;
Player[playerid][OwnedCarModSlot7] = 0;
Player[playerid][OwnedCarModSlot8] = 0;
Player[playerid][OwnedCarModSlot9] = 0;
Player[playerid][OwnedCarModSlot10] = 0;
Player[playerid][OwnedCarModSlot11] = 0;
Player[playerid][OwnedCarModSlot12] = 0;
Player[playerid][OwnedCarModSlot13] = 0;
Player[id][PlayerCarModel] = carid;
GetVehiclePos(Player[playerid][CarLinkID], Player[playerid][CarX], Player[playerid][CarY], Player[playerid][CarZ]);
GetVehicleZAngle(Player[playerid][CarLinkID], Player[playerid][CarZAngle]);
PutPlayerInVehicle(playerid,SpawnedVehicles[playerid],0);
SpawnOwnedCar(id, 1);
format(string, sizeof(string), "You have changed %s's car model %d for their owned car (slot 1)", GetName(id), carid);
SendClientMessage(playerid, WHITE, string);
}
else
{
Player[id][PlayerCarModel] = carid;
SpawnOwnedCar(id, 1);
format(string, sizeof(string), "You have given %s car model %d for their owned car (slot 1)", GetName(id), carid);
SendClientMessage(playerid, WHITE, string);
}
}
else
{
SendClientMessage(playerid, WHITE, "Invalid car ID!");
}
}
}
}
}
}
}
EDIT2: This will spawn the player in the car if any errors tell me.