Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Problem with /setcarpos command +REP

$
0
0
Info :
This command is using to set vehicles position to player owned house.
VIP Lv1 can own 3 vehicles and VIP Lv2 can own 6 vehicles.

Problem :
When i typed /setcarpos 6 as VIP Lv2, its show You have changed slot 6 position.
But when i typed /setcarpos 3 as VIP Lv1, its show You have changed slot 1 position, also when typed /setcarpos 2 or /setcarpos 1

Idk whats wrong with the script, i hope someone can help me to fix this problem. +REP for who helped me

The script :
Code:

CMD:setcarpos(playerid, params[])
{
        new playername[25], giveplayerid, string[256], slot, tmp[256];
        if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage2(playerid, COLOR_RED, "Error: You must be in a vehicle.");
        GetPlayerName(playerid, playername, 24);
        giveplayerid = dini_Int(AddDirFile(dir_userfiles, playername), "propowned");
        if (giveplayerid != 0)
        {
                if(sscanf(params, "d", slot)) slot = 1;
                else sscanf(params, "d", slot);
                if(vipmember[playerid] == 1)
                {
                    if(sscanf(params, "d", slot)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /setcarpos [slot 1-3]");
                    if(slot > 3 || slot < 1) return SendClientMessage(playerid, COLOR_RED, "Invalid slot id.");
                }
                if(vipmember[playerid] == 2)
                {
                    if(sscanf(params, "d", slot)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /setcarpos [slot 1-6]");
                    if(slot > 6 || slot < 1) return SendClientMessage(playerid, COLOR_RED, "Invalid slot id.");
                }
                else slot = 1;
                format(string, 10, "prop%d", giveplayerid);
                  new Float:x, Float:y, Float:z;
                GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
                if (PointToPoint2D(x, y, dini_Float(AddDirFile(dir_propfiles, string), "X"), dini_Float(AddDirFile(dir_propfiles, string), "Y")) > 50.0) return SendClientMessage2(playerid, COLOR_RED, "You must be at your property to change your vehicle position.");
                new Float:a;
                GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
                format(tmp, sizeof(tmp), "c%dX", slot);
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, x);
                format(tmp, sizeof(tmp), "c%dY", slot);
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, y);
                format(tmp, sizeof(tmp), "c%dZ", slot);
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, z);
                format(tmp, sizeof(tmp), "c%dA", slot);
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, a);
                if(vipmember[playerid] > 0)
                {
                    format(tmp, sizeof(tmp), "You have changed your vehicles slot %d position.", slot);
                    SendClientMessage2(playerid, COLOR_WHITE, tmp);
                }
                else SendClientMessage2(playerid, COLOR_WHITE, "You have changed your vehicles position.");
                return 1;
        }
        giveplayerid = dini_Int(AddDirFile(dir_userfiles, playername), "proprented");
        if (giveplayerid != 0)
        {
            format(string, 10, "prop%d", giveplayerid);
                new Float:x, Float:y, Float:z;
                GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
                if (PointToPoint2D(x, y, dini_Float(AddDirFile(dir_propfiles, string), "X"), dini_Float(AddDirFile(dir_propfiles, string), "Y")) > 50.0) return SendClientMessage2(playerid, COLOR_RED, "You must be at your property to change your vehicle position.");
                new Float:a;
                GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
                format(tmp, sizeof(tmp), "crX");
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, x);
                format(tmp, sizeof(tmp), "crY");
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, y);
                format(tmp, sizeof(tmp), "crZ");
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, z);
                format(tmp, sizeof(tmp), "crA");
                dini_FloatSet(AddDirFile(dir_propfiles, string), tmp, a);
                SendClientMessage2(playerid, COLOR_WHITE, "You have changed your vehicles position.");
                return 1;
        }
        else return SendClientMessage(playerid, COLOR_RED, "You don't own a property.");
}

Thanks a lot

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>