SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 11/02/2019, 09:24 PM   #1
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 257
Reputation: 25
Default A quick help

I have this code to check if the vehicle is of the owner:

pawn Code:
foreach(new i : PrivateVehicles[playerid])
{
if(!strcmp(vInfo[i][vehOwner], ReturnPlayerName(playerid)))
//This vehicle is yours
}
}

It works perfectly but i've a "problem". Is there a way to shorten this?

Since i have some vehicle related commands restriced only for vehicle owners, it's damn ugly and stupid write everytime this long code to check it.

I wanna do something like:

if(VehicleOwner(playerid) return "You're owner of this vehicle".

Hope i was clear, thanks.
SymonClash is offline   Reply With Quote
Old 11/02/2019, 11:00 PM   #2
AhmedMohamed
Huge Clucker
 
AhmedMohamed's Avatar
 
Join Date: Jan 2014
Location: Egypt
Posts: 338
Reputation: 3
Default Re: A quick help

pawn Code:
stock VehicleOwner(vehid, playerid)
{
if(!strcmp(vInfo[vehid][vehOwner], ReturnPlayerName(playerid)))
     return true;
return false;
}
AhmedMohamed is offline   Reply With Quote
Old 11/02/2019, 11:15 PM   #3
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,856
Reputation: 1292
Default Re: A quick help

Quote:
Originally Posted by AhmedMohamed View Post
pawn Code:
stock VehicleOwner(vehid, playerid)
{
if(!strcmp(vInfo[vehid][vehOwner], ReturnPlayerName(playerid)))
     return true;
return false;
}
That is horrible!
Why would you store the name? The ID is fine get the name when you need to.
Pottus is offline   Reply With Quote
Old 11/02/2019, 11:22 PM   #4
AhmedMohamed
Huge Clucker
 
AhmedMohamed's Avatar
 
Join Date: Jan 2014
Location: Egypt
Posts: 338
Reputation: 3
Default Re: A quick help

I really need the name because the Id is changing every time the playerr connect to the game
AhmedMohamed is offline   Reply With Quote
Old 12/02/2019, 12:05 AM   #5
Thundey
Little Clucker
 
Join Date: Jul 2013
Location: United Kingdom
Posts: 39
Reputation: 1
Default Re: A quick help

Not if u assign a perm ID to each user, then u can actually just store the ID assigned separately.
Thundey is offline   Reply With Quote
Old 12/02/2019, 12:17 AM   #6
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 257
Reputation: 25
Default Re: A quick help

@AhmedMohamed thanks, but what about the foreach loop?
SymonClash is offline   Reply With Quote
Old 12/02/2019, 01:52 PM   #7
SymonClash
Banned
 
Join Date: Dec 2018
Posts: 257
Reputation: 25
Default Re: A quick help

Ok thanks.
SymonClash 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
Quick Ans. ManGoe Scripting Help 2 07/12/2014 06:39 AM
Please a quick help about VPS :) TheArcher Everything and Nothing 17 29/09/2012 06:55 AM
Quick Help ThomasCarter Scripting Help 1 16/09/2012 01:17 PM
Quick help Slaykler Scripting Help 0 14/09/2012 02:35 PM
Quick Help Mini` Help Archive 3 24/05/2010 06:22 AM


All times are GMT. The time now is 01:59 AM.


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