Weired and Annoying
#1

pawn Код:
CMD:v(playerid, params[])
{
        new Index;
        new tmp[256];  tmp  = strtok(params,Index);
        new tmp2[256]; tmp2 = strtok(params,Index);
        new tmp3[256]; tmp3 = strtok(params,Index);
        if(!strlen(tmp)) return
        SendClientMessage(playerid, COLOR_RED, "Usage: /car [ModelID/Name] [Colour1] [Colour2]") &&
        SendClientMessage(playerid, COLOR_RED, "Function: Will create a Car with specified Colours");
        new car;
        new string[128];
        new colour1, colour2;
        if(!IsNumeric(tmp))
        car = GetVehicleModelIDFromName(tmp);
        else car = strval(tmp);
        if(car < 400 || car > 611) return  SendClientMessage(playerid, COLOR_BLUE, "ERROR: Invalid Vehicle Model ID!");
        if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
        if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);

        new LVehicleID,pWorld;
        pWorld = GetPlayerVirtualWorld(playerid);
        new Float:X,Float:Y,Float:Z;
        new Float:Angle,int1;
        GetPlayerFacingAngle(playerid,Angle);
        int1 = GetPlayerInterior(playerid);
        GetXYInFrontOfPlayer(playerid, X, Y, 1.5);
        LVehicleID = CreateVehicle(car, X, Y, Z+0.5, Angle+90, colour1, colour2, -1);
        LinkVehicleToInterior(LVehicleID,int1);
        SetVehicleVirtualWorld(LVehicleID, pWorld);
        format(string, sizeof(string), "|- You have Spawned a \"%s\" (Model: %d) with Colours: %d,%d -|", VehicleNames[car-400], car, colour1, colour2);
        return SendClientMessage(playerid, COLOR_BLUE, string);
}


GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{   // Created by ******

    new Float:a;

    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);

    if (GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
These cmd spawn me a car but on weired way....
i use cmd and i need to wait whole 3 sec!and car spawn's at closest ROAD!
WTF?
And i know about code optimization i will do that later just to find out why is these bug happening...
(Windows server 0.3bR2)
Reply
#2

I don't see you using GetPlayerPos in that code.

pawn Код:
CMD:v(playerid,params[])
{
        new Float:X, Float:Y, Float:Z, string[128], tmp[256], Index, veh, vehid;
        tmp = strtok(params,Index), vehid = strval(tmp); GetPlayerPos(playerid,X,Y,Z);
        if(!strlen(tmp)) return SendClientMessage(playerid,red,"USAGE: /car [model]");
        if(!IsNumeric(tmp)) vehid = GetVehicleModelIDFromName(tmp); else vehid = strval(tmp);
        if(vehid < 400 || vehid > 611) return  SendClientMessage(playerid, red, "ERROR: Invalid Vehicle Model");
        if(PlayerInfo[playerid][pCar] == 0)
        {
            veh = AddStaticVehicle(vehid,X+3,Y,Z,90,17,17);
            PlayerInfo[playerid][pCar] = 1;
            format(string,sizeof(string),"FCAR- CARNAME: %s (%d) COLOR: Red, Red(17,17)",VehicleNames[vehid-400],vehid);
            SendClientMessage(playerid,purple,string);
        } else {
            DestroyVehicle(veh);
            veh = AddStaticVehicle(vehid,X+3,Y,Z,90,17,17);
            format(string,sizeof(string),"FCAR- CARNAME: %s (%d) COLOR: Red, Red(17,17)",VehicleNames[vehid-400],vehid);
            SendClientMessage(playerid,purple,string);
        }
    return 1;
}
There is a perfect one... Color is auto red(17, 17). Also Its not indented perfectly.
Reply
#3

I dont need to use it....there is GetXYInFrontOfPlayer

[EDIT]
WoW thx man
Problem is that i didnt used GetPlayerPos
Still dont get why but nvm
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)