SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/02/2020, 12:08 PM   #1
VGAassassin
Little Clucker
 
Join Date: Jul 2017
Posts: 31
Reputation: 0
Default car verify

How can i make a car verification, i put a permission in car where i'm stay and with a towcar i can tow him?
CMD:grantpermission( playerid, params[ ] ) {
new vehicleid, pID;
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
if( sscanf( params, "i", vehicleid, pID) ) return SendClientMessage( playerid, -1, "| USAGE: | /grantpermission [car]" );
return Tow_StoreCars(vehicleid, playerid);
}
else SendClientMessage(playerid, -1, "You're not in car!");
return 1;
}
Tow_StoreCars( vehicleid, playerid ) {
vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 0 || vehicleid >= MAX_VEHICLES) return SendClientMessage(playerid, COLOR_GENERAL, "Car doens't exist.");
SendClientMessage( playerid, -1, "{17BF41}You offered the permission!");
Permission[vehicleid] = 1;
return ( true );
}
VGAassassin is offline   Reply With Quote
Old 16/02/2020, 12:29 PM   #2
SiaReyes
Gangsta
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 623
Reputation: 57
Default Re: car verify

https://pastebin.com/SAAGSqWk

You mean something like this?
SiaReyes is offline   Reply With Quote
Old 16/02/2020, 12:38 PM   #3
VGAassassin
Little Clucker
 
Join Date: Jul 2017
Posts: 31
Reputation: 0
Default Re: car verify

Quote:
Originally Posted by SiaReyes View Post
https://pastebin.com/SAAGSqWk

You mean something like this?
Yeah.
1. error 028: invalid subscript (not an array or too many subscripts): "Permission"
2. error 001: expected token: ";", but found "]"
3. error 029: invalid expression, assumed zero
4. fatal error 107: too many error messages on one line

Is only line with errors if(Permission[GetPlayerVehicleID(pID)] == 1) return SendClientMessage(playerid, -1, "Premission is already given to that vehicle.");

but, i get some errors from the code and i don't know what the hell i need to fix
VGAassassin is offline   Reply With Quote
Old 16/02/2020, 12:44 PM   #4
SiaReyes
Gangsta
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 623
Reputation: 57
Default Re: car verify

Quote:
Originally Posted by VGAassassin View Post
Yeah.
1. error 028: invalid subscript (not an array or too many subscripts): "Permission"
2. error 001: expected token: ";", but found "]"
3. error 029: invalid expression, assumed zero
4. fatal error 107: too many error messages on one line

Is only line with errors if(Permission[GetPlayerVehicleID(pID)] == 1) return SendClientMessage(playerid, -1, "Premission is already given to that vehicle.");

but, i get some errors from the code and i don't know what the hell i need to fix
is it like
Code:
 new Permission[MAX_VEHICLES];
SiaReyes is offline   Reply With Quote
Old 16/02/2020, 12:52 PM   #5
VGAassassin
Little Clucker
 
Join Date: Jul 2017
Posts: 31
Reputation: 0
Default Re: car verify

Quote:
Originally Posted by SiaReyes View Post
is it like
Code:
 new Permission[MAX_VEHICLES];
Thanks for the code but i have 1 problem, and last.
When I give / my grantpermission id it works fine and when I give / towcar it tells me that it does not have a car permit

btw i give you rep+
VGAassassin is offline   Reply With Quote
Old 16/02/2020, 12:59 PM   #6
SiaReyes
Gangsta
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 623
Reputation: 57
Default Re: car verify

Quote:
Originally Posted by VGAassassin View Post
Thanks for the code but i have 1 problem, and last.
When I give / my grantpermission id it works fine and when I give / towcar it tells me that it does not have a car permit

btw i give you rep+
You gave permission to yourself?

Code:
Permission[vehicleid] = 0;
Put this line in vehicle spawn code.
SiaReyes is offline   Reply With Quote
Old 16/02/2020, 01:57 PM   #7
VGAassassin
Little Clucker
 
Join Date: Jul 2017
Posts: 31
Reputation: 0
Default Re: car verify

Quote:
Originally Posted by SiaReyes View Post
You gave permission to yourself?

Code:
Permission[vehicleid] = 0;
Put this line in vehicle spawn code.
Thanks, I solved it.
But if I want to add these cars in a dialog how could I do this, / towcars ​​and write all the cars with permission.
VGAassassin is offline   Reply With Quote
Old 16/02/2020, 02:22 PM   #8
SiaReyes
Gangsta
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 623
Reputation: 57
Default Re: car verify

Quote:
Originally Posted by VGAassassin View Post
Thanks, I solved it.
But if I want to add these cars in a dialog how could I do this, / towcars ​​and write all the cars with permission.
Code:
CMD:towcars(playerid)
{
  new carslist[250];
  for(new v = 0, i=0; v < MAX_VEHICLES, i < MAX_PLAYERS ;v++,i++) if(Permission[v] == 1)
  {
     if(GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerInVehicle(i,v))
     {
     format(carslist, sizeof carslist, "Vehicle ID: %i || Player ID: %i \n", v, i); 
    }
  }
  ShowPlayerDialog (playerid, dialogid, DIALOG_STYLE_LIST, "Towcars list", carslist, "Select", "Close");
  return 1;
}
SiaReyes is offline   Reply With Quote
Old 16/02/2020, 03:15 PM   #9
VGAassassin
Little Clucker
 
Join Date: Jul 2017
Posts: 31
Reputation: 0
Default Re: car verify

Quote:
Originally Posted by SiaReyes View Post
Code:
CMD:towcars(playerid)
{
  new carslist[250];
  for(new v = 0, i=0; v < MAX_VEHICLES, i < MAX_PLAYERS ;v++,i++) if(Permission[v] == 1)
  {
     if(GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerInVehicle(i,v))
     {
     format(carslist, sizeof carslist, "Vehicle ID: %i || Player ID: %i \n", v, i); 
    }
  }
  ShowPlayerDialog (playerid, dialogid, DIALOG_STYLE_LIST, "Towcars list", carslist, "Select", "Close");
  return 1;
}
Nothing happen man
VGAassassin is offline   Reply With Quote
Old 16/02/2020, 03:42 PM   #10
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 822
Reputation: 68
Default Re: car verify

Quote:
Originally Posted by SiaReyes View Post
...
1) Vehicles ID starts from 1, not 0.
2) Check if the vehicle is valid before doing anything.
3) Use foreach.
4) You don't need IsPlayerInVehicle check because if the player is the driver obviously is in a vehicle.
5) Create a count and return an error if you don't have any permission for any vehicle.

pawn Code:
CMD:towcars(playerid)
{
    new carslist[200], count = 0;

    for(new v = 1; v <= MAX_VEHICLES; v ++) if(IsValidVehicle(v))
    {
        foreach(new i : Player) if(Permission[v] == 1 && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            format(carslist, sizeof(carslist), "Vehicle ID: %d || Player ID: %d\n", v, i);
            count ++;
        }
    }

    if(count)
    {
        ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Towcars list", carslist, "Select", "Close");
    }
    else
    {
        SendClientMessage(playerid, -1, "You don't have any permission for any vehicle.");
    }
    return 1;
}

Not tested.
__________________


"A server owner shouldn't be embarrassed or have fear to request help, because we're humans and we never stop learning."
Symon 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
How likely are you to verify your email address Isolated Everything and Nothing 18 16/12/2017 09:35 AM
verify email address format angelxeneize Scripting Help 1 15/09/2016 02:32 AM
get player name and verify [+1 rep] driftpower Server Support 6 01/01/2012 03:25 AM
verify if a player is near [SOB]Chris Help Archive 2 19/09/2009 03:37 PM


All times are GMT. The time now is 11:31 PM.


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