Car vipname bug
#1

Hello!
I just made a car vipname script in my gamemode using ZCMD , it works good for a player,
but when a player assign it to his car it assings to all cars in the server, and after server restart it didn't appear until you do the command again.
PHP код:
CMD:vipname(playeridparams[])
{
    new 
text[6], szMessage[256];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
sscanf(params"s[50]"text)) return SCM(playeridCOLOR_WHITE"SYNTAX: /vipname [name]");
    if(
PlayerInfo[playerid][pPremiumAccount] != 1) return SCM(playeridCOLOR_ERROR"You don't have a premium account");
    {
        if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SCM(playeridCOLOR_WHITE"You aren't in any car.");
        if(
GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SCM(playeridCOLOR_ERROR"You aren't the driver.");
        if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 411) return SCM(playeridCOLOR_ERROR"Car must be an Infernus in order to apply this command.");
        if(
OwnedVeh(vehicleid))
        {
            
vText CreateObject(19327, -2597.0762, -2638.4270, -5.3536, -87.699990.4001, -87.1805);
            
SetObjectMaterialText(vTexttext050"Arial"1510xFFFFFFFF01);
            
AttachObjectToVehicle(vTextvehicleid0.0,-1.90.3270.00.00.0);
            
format(szMessagesizeof(szMessage), "{F2CF09}Vipname is: '%s'"text);
            
SCM(playeridCOLOR_YELLOWszMessage);
        }
    }
    return 
1;
}
CMD:removename(playeridparams[])
{
    new 
szMessage[256];
    if(
PlayerInfo[playerid][pPremiumAccount] == 1)
    {
        if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER) return SCM(playeridCOLOR_WHITE"You aren't in a vehicle.");
        
DestroyObject(vText);
        
format(szMessagesizeof(szMessage), "{F2CF09}Car vipname removed with success!");
        
SCM(playeridCOLOR_REDszMessage);
    }
    return 
1;

So i have 2 bugs over now:
  • It didn't save
  • It attach to all players in server
help me please,
also, i'm new here !
Reply
#2

Wiki says:
Quote:

Important
Note
When the vehicle is destroyed or respawned, the attached objects won't be destroyed with it; they will remain stationary at the position the vehicle disappeared and be reattached to the next vehicle to claim the vehicle ID that the objects were attached to.

but it shouldn't be attached to all cars, also, your variable vText seems to be global and you can't sue the same variable for every player, create an array like this:

PHP код:
new vText[MAX_PLAYERS]; 
By the way, here, i made your actual code less messy:

PHP код:
CMD:vipname(playeridparams[]) 

    new 
text[50]; 
    
    if(
sscanf(params"s[50]"text)) return SCM(playeridCOLOR_WHITE"SYNTAX: /vipname [name]"); 
    if(
PlayerInfo[playerid][pPremiumAccount] != 1) return SCM(playeridCOLOR_ERROR"You don't have a premium account"); 
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SCM(playeridCOLOR_ERROR"You aren't driving a vehicle."); 
    new 
vehicleid GetPlayerVehicleID(playerid); 
    if(
GetVehicleModel(vehicleid) != 411) return SCM(playeridCOLOR_ERROR"Car must be an Infernus in order to apply this command."); 
    if(
OwnedVeh(vehicleid)) return SCM(playeridCOLOR_ERROR"This vehicle doesn't belong to you."); 
    { 
        
vText CreateObject(19327, -2597.0762, -2638.4270, -5.3536, -87.699990.4001, -87.1805); 
        
SetObjectMaterialText(vTexttext050"Arial"1510xFFFFFFFF01); 
        
AttachObjectToVehicle(vTextvehicleid0.0,-1.90.3270.00.00.0); 
        new 
szMessage[80];
        
format(szMessagesizeof(szMessage), "{F2CF09}Vipname is: '%s'"text); 
        
SCM(playeridCOLOR_YELLOWszMessage); 
    }  
    return 
1

CMD:removename(playeridparams[]) 

    if(
PlayerInfo[playerid][pPremiumAccount] == 1
    { 
        if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER) return SCM(playeridCOLOR_WHITE"You aren't in a vehicle."); 
        
DestroyObject(vText); 
        
SCM(playeridCOLOR_RED"{F2CF09}Car vipname removed with success!"); 
    } 
    return 
1

Reply
#3

I saw it, it was
new vText;
Now i have 1 problem left , it is saving so when server restarts the vText will be attached to vehicles back .
Note: i have Mysql , it can be used to save vText ? if so, help me.
Reply
#4

Yes it can, create a varchar(treated as a string in pawn) with the size of 50+ (dunno what length u want) column and do what you usually do when you load / save player data
Reply
#5

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Yes it can, create a varchar(treated as a string in pawn) with the size of 50+ (dunno what length u want) column and do what you usually do when you load / save player data
Ah ok, but i don't know too much about MySQL :/
I will try and if i got an error i will post it here
Reply
#6

Quote:
Originally Posted by YouHack
Посмотреть сообщение
Ah ok, but i don't know too much about MySQL :/
I will try and if i got an error i will post it here
Sure, good luck
Reply
#7

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Sure, good luck
Bro,, i'm stuck with how to create a new column for all users in `users` table ?
Reply
#8

You can create new columns easily, you dont have to create them for every single tupel.

You just change the tables structure by doing that:

http://www.w3schools.com/sql/sql_alter.asp
Reply
#9

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
You can create new columns easily, you dont have to create them for every single tupel.

You just change the tables structure by doing that:

http://www.w3schools.com/sql/sql_alter.asp
And how much length string for the varchar ?
Reply
#10

thats your choice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)