A quick help
#1

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

pawn Код:
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.
Reply
#2

pawn Код:
stock VehicleOwner(vehid, playerid)
{
if(!strcmp(vInfo[vehid][vehOwner], ReturnPlayerName(playerid)))
     return true;
return false;
}
Reply
#3

Quote:
Originally Posted by AhmedMohamed
Посмотреть сообщение
pawn Код:
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.
Reply
#4

I really need the name because the Id is changing every time the playerr connect to the game
Reply
#5

Not if u assign a perm ID to each user, then u can actually just store the ID assigned separately.
Reply
#6

@AhmedMohamed thanks, but what about the foreach loop?
Reply
#7

Ok thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)