My Werewolf Script
#1

PHP Code:
#include <a_samp>
#include <zcmd>
#define FILTERSCRIPT
new jumping[MAX_PLAYERS];
new 
activate[MAX_PLAYERS];
public 
OnFilterScriptInit()
{
print(
"Werewolf System");
}
public 
OnFilterScriptExit()
{
print(
"Werewolf System");
}
CMD:shift(playeridparams[])
{
SetPlayerSkin(playerid0);
SetPlayerArmour(playerid1000);
SetPlayerHealth(playerid1000);
SetPlayerName(playerid"Werewolf");
SetPlayerColor(playerid0x0000FFAA);
GivePlayerWeapon(playerid11);
SendClientMessage(playerid0x0000FFAA"You have transform to a Werewolf");
return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
jumping[playerid] = 0;
return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
if(
activate[playerid] == 1)
{
if(
newkeys == KEY_JUMP && jumping[playerid] == 0)
{
jumping[playerid] == 1;
{
new 
Float:werewolf_jump[3];
GetPlayerVelocity(playeridwerewolf_jump[0], werewolf_jump[1], werewolf_jump[2]);
SetPlayerVelocity(playeridwerewolf_jump[0]+100werewolf_jump[1]+100werewolf_jump[2]+100);
}
}
}
return 
1;

I need help with this script, what I have is when I type /shift I transform to a werewolf but my superjump and speed doesn't work... help me, check it out.
Reply
#2

Code:
CMD:shift(playerid, params[]) 
{ 
SetPlayerSkin(playerid, 0); 
SetPlayerArmour(playerid, 1000); 
SetPlayerHealth(playerid, 1000); 
SetPlayerName(playerid, "Werewolf"); 
SetPlayerColor(playerid, 0x0000FFAA); 
GivePlayerWeapon(playerid, 1, 1);
activate[playerid] = 1; // Set "activate" to 1.
SendClientMessage(playerid, 0x0000FFAA, "You have transform to a Werewolf");
return 1; 
}
You missed to add this:
Code:
activate[playerid] = 1;
The check in OnPlayerKeyStateChange will work now.
Reply
#3

Alright, the super jump works but it only works 1 time. When I type /shift I become a werewolf but the super jump isn't use everytime it only works once. Help me out here.
Reply
#4

Quote:
Originally Posted by Heroleo911003
View Post
Alright, the super jump works but it only works 1 time. When I type /shift I become a werewolf but the super jump isn't use everytime it only works once. Help me out here.
So.. You have to reset the variable. But, i don't really understand why there is jumping[playerid].
Anyway, try this way (the player can jump as he wants) :

PHP Code:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
activate[playerid] == 1)
    {
        if(
newkeys == KEY_JUMP && jumping[playerid] == 0)
        {
            new 
Float:werewolf_jump[3];
            
GetPlayerVelocity(playeridwerewolf_jump[0], werewolf_jump[1], werewolf_jump[2]);
            
SetPlayerVelocity(playeridwerewolf_jump[0]+100werewolf_jump[1]+100werewolf_jump[2]+100);
        }
    }
    return 
1;

or :
PHP Code:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
activate[playerid] == 1)
    {
        if(
newkeys == KEY_JUMP)
        {
            new 
Float:werewolf_jump[3];
            
GetPlayerVelocity(playeridwerewolf_jump[0], werewolf_jump[1], werewolf_jump[2]);
            
SetPlayerVelocity(playeridwerewolf_jump[0]+100werewolf_jump[1]+100werewolf_jump[2]+100);
        }
    }
    return 
1;

Reply
#5

http://pastebin.com/TnSwJ8UR
my strcmps won't work when I type /shift 1,
why? Plz help me.
Reply
#6

You don't need sscanf for such a simple check in your "shift" command. Observe:
PHP Code:
CMD:shift(playeridparams[])
{
    if (
isnull(params)) return SendClientMessage(playerid0xFFEEFFAA"USAGE: /form [1-3]");
    switch (
params[0])
    {
        case 
'1':
        {
            
SetPlayerTeam(playeridHomid);
            
GameTextForPlayer(playerid"~W~Form: ~G~Homid"50006);
        }
        case 
'2':
        {
            
SetPlayerTeam(playeridCrinos);
            
GameTextForPlayer(playerid"~W~Form: ~G~Crinos"50006);
        }
        case 
'3':
        {
            
SetPlayerTeam(playeridLupus);
            
GameTextForPlayer(playerid"~W~Form: ~G~Lupus"50006);
        }
    }
    
// If you have more than 9 options, use strval:
    /*
    new choice = strval(params[0]);
    if (choice == 1)
    else if (choice == 2)
    // etc
    */
    
if (GetPlayerTeam(playerid) == Homid)
    {
        
SendClientMessage(playerid, -1"You've shifted into the form homid(human)");
        
SetPlayerHealth(playerid150);
        
SetPlayerArmour(playerid50);
        
//werewolf_speed required
    
}
    return 
1;

Edit:
If you use zcmd it comes with it. It_compiles_fine.
Reply
#7

Undefined symbol isnull?
Reply
#8

Use sscanf it's more easier.
PHP Code:
CMD:shift(playeridparams[])
{
    if(
sscanf(params,"i"params)) return SendClientMessage(playerid0xFFEEFFAA"USAGE: /form [1-3]");

    switch (
params[0])
    {
        case 
'1':
        {
            
SetPlayerTeam(playeridHomid);
            
GameTextForPlayer(playerid"~W~Form: ~G~Homid"50006);
        }
        case 
'2':
        {
            
SetPlayerTeam(playeridCrinos);
            
GameTextForPlayer(playerid"~W~Form: ~G~Crinos"50006);
        }
        case 
'3':
        {
            
SetPlayerTeam(playeridLupus);
            
GameTextForPlayer(playerid"~W~Form: ~G~Lupus"50006);
        }
    }
    
// If you have more than 9 options, use strval:
    /*
    new choice = strval(params[0]);
    if (choice == 1)
    else if (choice == 2)
    // etc
    */
    
if (GetPlayerTeam(playerid) == Homid)
    {
        
SendClientMessage(playerid, -1"You've shifted into the form homid(human)");
        
SetPlayerHealth(playerid150);
        
SetPlayerArmour(playerid50);
        
//werewolf_speed required
    
}
    return 
1;

If you don't want, define isnull().
PHP Code:
#if !defined isnull
    #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif 
Reply
#9

Thx, I'll try both of them to see which works better.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)