SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/04/2017, 04:49 PM   #11
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: Please help me

Quote:
Originally Posted by Meller View Post
Well first off:
LAbels that are attached to a vehicle cannot be seen if you're inside the vehicle.
Step out.

Second,
You should read your code again and recreate the command aswell as the function as you havef unneeded shit in it, nothing too much for a harm doe.
First: Bullshit

Second: yes. The actual code is shit.
GangstaSunny. is offline   Reply With Quote
Old 13/04/2017, 12:35 AM   #12
Imbalo
Big Clucker
 
Join Date: Mar 2017
Location: Indonesia
Posts: 66
Reputation: 0
Default Re: Please help me

Can you give an example of the script. So that I can make 3DTextLabel in a vehicle that I've made.
Imbalo is offline   Reply With Quote
Old 13/04/2017, 07:48 AM   #13
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

PHP Code:
CMD:test(playeridparams[]) {
   new 
Text3D:label_idvehicle_id;
   
vehicle_id GetPlayerVehicleID(playerid);
   if(
vehicle_id 0) {
      new 
string[64];
      
format(string64"%s\nFor sale"params);
      
label_id Create3DTextLabel(string0x008080FF0.00.00.040.001);
      
Attach3DTextLabelToVehicle(label_idvehicle_id002.0);
   }
   else
      
SendClientMessage(playerid, -1"Error, you must be inside a vehicle to attach a label.");
   return 
1;

Not tested btw, wrote in the webbrowser but this works atleast.
Meller is offline   Reply With Quote
Old 13/04/2017, 07:57 AM   #14
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: Please help me

Quote:
Originally Posted by Meller View Post
PHP Code:
CMD:test(playeridparams[]) {
   new 
Text3D:label_idvehicle_id;
   
vehicle_id GetPlayerVehicleID(playerid);
   if(
vehicle_id 0) {
      new 
string[64];
      
format(string64"%s\nFor sale"params);
      
label_id Create3DTextLabel(string0x008080FF0.00.00.040.001);
      
Attach3DTextLabelToVehicle(label_idvehicle_id002.0);
   }
   else
      
SendClientMessage(playerid, -1"Error, you must be inside a vehicle to attach a label.");
   return 
1;

Not tested btw, wrote in the webbrowser but this works atleast.
What....The... How do you code dafuq?

PHP Code:
CMD(playerid,params[])
{
    if(
GetPlayerVehicleID(playerid) == INVALID_VEHICLE_ID)return SendClientMessage (playerid,0xFFFFFFFF,"You are not inside a vehicle.");
    
//Create
    //Attach
    
return true;

I highly recommend to check whether the user is in a car or in an airplane. Also maybe check whether the player is die driver or not.
GangstaSunny. is offline   Reply With Quote
Old 13/04/2017, 09:09 AM   #15
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

Quote:
Originally Posted by GangstaSunny. View Post
What....The... How do you code dafuq?

PHP Code:
CMD(playerid,params[])
{
    if(
GetPlayerVehicleID(playerid) == INVALID_VEHICLE_ID)return SendClientMessage (playerid,0xFFFFFFFF,"You are not inside a vehicle.");
    
//Create
    //Attach
    
return true;

I highly recommend to check whether the user is in a car or in an airplane. Also maybe check whether the player is die driver or not.
Excuse me?
What the fuck is wrong with the way I did?
Also, GetPlayerVehicleID returns 0 if it's an invaldi vehicle, so pls. remove INVALID_VEHICLE_ID

Also, learn a little bit before complaining at someones coding style. You can type your code on hundreds different ways, but nothing is wrong. Your code makes it messy. My code keeps it clean and you'll be able to read it better.

It's the same question like:

PHP Code:
class SomeThing {
   protected 
$mysql;
   public function 
__construct() {
      if(
$this->mysql = new mysqli(somesomesome ,some)) {
         echo 
"mysql has connected";
      }
      else {
         echo 
"sumthing went wrun";
      }
   }

Tell me what's wrong? Nothing at all, please learn something called a language and try call me out for coding like shit.
Meller is offline   Reply With Quote
Old 13/04/2017, 09:37 AM   #16
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,243
Reputation: 525
Default Re: Please help me

Using 0 instead of INVALID_VEHICLE_ID is simply aesthetic, but it encourages using fixed values... It's more indicative to the coder that that is what they are looking for.

You should really be using INVALID_VEHICLE_ID.


Also when you run your command, you're making all the variables BEFORE you check if they are in a vehicle (Which you didn't) and that's simply a waste... That's like making the command make every variable for the command, before checking if they didn't type anything in the end and returning a simple syntax message.
Sew_Sumi is offline   Reply With Quote
Old 13/04/2017, 10:24 AM   #17
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: Please help me

Quote:
Originally Posted by Meller View Post
Excuse me?
What the fuck is wrong with the way I did?
Also, GetPlayerVehicleID returns 0 if it's an invaldi vehicle, so pls. remove INVALID_VEHICLE_ID

Also, learn a little bit before complaining at someones coding style. You can type your code on hundreds different ways, but nothing is wrong. Your code makes it messy. My code keeps it clean and you'll be able to read it better.

It's the same question like:

PHP Code:
class SomeThing {
   protected 
$mysql;
   public function 
__construct() {
      if(
$this->mysql = new mysqli(somesomesome ,some)) {
         echo 
"mysql has connected";
      }
      else {
         echo 
"sumthing went wrun";
      }
   }

Tell me what's wrong? Nothing at all, please learn something called a language and try call me out for coding like shit.
My code looks messy to you? Seems like you don't know shit about a good coding style.

Your code is old and looks like you've open pawno for the first time just 2 days ago.

Why do you post a php code here? It has nothing to do with this question.

You really should INVALID_VEHICLE_ID. Don't forget reset variables for destroyed vehicles.

To be 100% sure use "IsValidVehicle". This is not defined as native so you have to do it by yourself. But it's in the samp source code.
GangstaSunny. is offline   Reply With Quote
Old 13/04/2017, 11:46 AM   #18
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

Quote:
Originally Posted by GangstaSunny. View Post
My code looks messy to you? Seems like you don't know shit about a good coding style.

Your code is old and looks like you've open pawno for the first time just 2 days ago.

Why do you post a php code here? It has nothing to do with this question.

You really should INVALID_VEHICLE_ID. Don't forget reset variables for destroyed vehicles.

To be 100% sure use "IsValidVehicle". This is not defined as native so you have to do it by yourself. But it's in the samp source code.
So? Let my code look "old", does it have anything to do with you? No it's my code and I like how I style my coding.
Meller is offline   Reply With Quote
Old 13/04/2017, 11:59 AM   #19
GangstaSunny.
Huge Clucker
 
GangstaSunny.'s Avatar
 
Join Date: Apr 2010
Location: Hamburg - Germany
Posts: 244
Reputation: 41
Default Re: Please help me

Quote:
Originally Posted by Meller View Post
So? Let my code look "old", does it have anything to do with you? No it's my code and I like how I style my coding.
Okay so then let us watch your code.
You are creating a variable names vehicleid. But i the player is not in any vehicle your variable was created only to use a resource "for free" because she is going to be useless.

You should better create the variable after checking whether he's in a vehicle or not.
Also the same with the 3DText. If the player is not in any vehicle your created 3DText becomes useless but still pawn had to declare ist. Just because your style is shit.

Also you don't check any params so if he is in a vehicle but he just wrote the command without a param you will have an empty %s. Well done.


In the end:
2 variables which becomes useless but use resources of the server.
1empty string mistake in 13 lines of code which includes nothing than basics.

Well done. Your style is officially shit.
GangstaSunny. is offline   Reply With Quote
Old 13/04/2017, 12:41 PM   #20
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Please help me

Quote:
Originally Posted by GangstaSunny. View Post
Okay so then let us watch your code.
You are creating a variable names vehicleid. But i the player is not in any vehicle your variable was created only to use a resource "for free" because she is going to be useless.

You should better create the variable after checking whether he's in a vehicle or not.
Also the same with the 3DText. If the player is not in any vehicle your created 3DText becomes useless but still pawn had to declare ist. Just because your style is shit.

Also you don't check any params so if he is in a vehicle but he just wrote the command without a param you will have an empty %s. Well done.


In the end:
2 variables which becomes useless but use resources of the server.
1empty string mistake in 13 lines of code which includes nothing than basics.

Well done. Your style is officially shit.
Since you're calling me and my code aswell as styling shit, tell me what's shit with this small snippet I just randomly took from a script:
PHP Code:
CMD:spawnvehicle(playeridparams[]) {
    if(
Player[playerid][p->rank] >= RANK_ADMIN) {
        if(
HasAdminSpawnedVehicle[playerid] == 0) {
            new 
model;
            if(!
sscanf(params"i"model)) {
                new 
Float:xFloat:yFloat:zFloat:a;
                
GetPlayerPos(playeridxyz);
                
GetPlayerFacingAngle(playerida);
                
HasAdminSpawnedVehicle[playerid] = CreateVehicle(modelxyza66, -10);
                
PutPlayerInVehicle(playeridHasAdminSpawnedVehicle[playerid], 0);
            }
            else
                
SendClientMessage(playerid0""WarningColor"Syntax"NormalColor" > /spawnvehicle [model]");
        }
        else
            
SendClientMessage(playerid0""ErrorColor"Error"NormalColor" > You must despawn your current admin vehicle first!");
    }
    else
        
SendClientMessage(playerid0""ErrorColor"Error"NormalColor" > You're not authorized to use this command!");
    return 
1;


Hm? Nothing? Alright, thanks.
Meller 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



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


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