SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/07/2016, 11:47 AM   #1
madl
Little Clucker
 
Join Date: Jul 2016
Posts: 1
Reputation: 0
Question Problem with Getting player vehicles and spawn them

Hello.I'm Very new to this forum and to Pawn.i Was trying to Get the Player's vehicles(the vehicles which a player owns) and then spawn them.but i get lots of error like Array must be index and other that i have attached in the end of the post.i really have no idea why i get these errors and i tried searching ****** and the forum,but i couldnt get a result

pawn Code:
GetPlayerVehicles(playerid){
    new vehicles[50][32];
    new ind;
    ind=0;
    for(new i;i<MAX_VEHICLES;i++)
    {
        if(VehicleInfo[i][cOwner]== PlayerInfo[playerid][pName])
        {
            vehicles[ind]=i;
            ind++;
        }
    }
    return vehicles;
}
SpawnPlayerVehicles(playerid)
{
    new fields = GetPlayerVehicles(playerid);
    new length[10] = sizeof(fields);
    new id;
    for (new i;i<length;i++)
    {
        id = strval(fields[i]);
        CreateVehicle(VehicleInfo[id][cModel],VehicleInfo[id][cLocationX],VehicleInfo[id][cLocationY],VehicleInfo[id][cLocationZ],VehicleInfo[id][cAngle],VehicleInfo[id][cColor1],VehicleInfo[id][cColor2],0);
        }
}

Errors:

Code:
array must be indexed (variable "vehicles")
array must be indexed (variable "-unknown-")// on new fields = GetPlayerVehicles(playerid);
array must be indexed (variable "length")
invalid subscript (not an array or too many subscripts): "fields"//On id = strval(fields[i]);
warning 215: expression has no effectid = strval(fields[i]);//On id = strval(fields[i]);
error 001: expected token: ";", but found "]"//On id = strval(fields[i]);
error 029: invalid expression, assumed zero//On id = strval(fields[i]);
fatal error 107: too many error messages on one line//On id = strval(fields[i]);
7 Errors.
I Hope Someone can help me to make these functions correct and fix the errors
madl is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Per-player vehicles - Id's get mixed up (Car stealing problem) denNorske Scripting Help 8 17/06/2015 12:21 PM
Spawn player problem.. dundolina Scripting Help 7 10/03/2015 07:17 PM
> Problem with loading player vehicles.. Jacapo Scripting Help 4 15/01/2014 04:15 PM
On Player Spawn problem alainchaccour Scripting Help 3 29/08/2011 01:49 PM
Spawn Vehicles Underground Problem Alec24 Help Archive 3 05/09/2009 01:06 AM


All times are GMT. The time now is 08:13 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.